-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8e6a04
commit bf72162
Showing
4 changed files
with
75 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
packages/lb-components/src/components/pointCloudView/hooks/usePointCloudAttribute.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { useContext } from 'react'; | ||
import { PointCloudContext } from '../PointCloudContext'; | ||
import { useUpdatePointCloudColor } from './useUpdatePointCloudColor'; | ||
import { useAttribute } from './useAttribute'; | ||
import { usePolygon } from './usePolygon'; | ||
import { useLine } from './useLine'; | ||
import { useSphere } from './useSphere'; | ||
import { useHistory } from './useHistory'; | ||
import { usePointCloudViews } from './usePointCloudViews'; | ||
|
||
export const usePointCloudAttribute = (setResourceLoading: any, config: any) => { | ||
const { updatePointCloudColor } = useUpdatePointCloudColor(setResourceLoading, config); | ||
const { syncThreeViewsAttribute } = useAttribute(); | ||
const { selectedPolygon } = usePolygon(); | ||
const { selectedLine } = useLine(); | ||
const { selectedSphere } = useSphere(); | ||
const { updatePointCloudSphere } = useSphere(); | ||
const { pushHistoryUnderUpdatePolygon, pushHistoryUnderUpdateLine } = useHistory(); | ||
const { topViewSelectedChanged } = usePointCloudViews(); | ||
const ptCtx = useContext(PointCloudContext); | ||
|
||
const updatePointCloudAttribute = (newAttribute: string) => { | ||
syncThreeViewsAttribute(newAttribute); | ||
|
||
/** | ||
* The logic for extracting the updated color of the original point cloud due to changes in the main attribute, | ||
* which originally only supported single selection, now supports multiple selection, and merges to reduce the number of updates | ||
*/ | ||
updatePointCloudColor(newAttribute); | ||
|
||
if (selectedPolygon) { | ||
pushHistoryUnderUpdatePolygon({ ...selectedPolygon, attribute: newAttribute }); | ||
} | ||
if (selectedLine) { | ||
pushHistoryUnderUpdateLine({ ...selectedLine, attribute: newAttribute }); | ||
} | ||
if (selectedSphere) { | ||
const newSphereList = updatePointCloudSphere({ | ||
...selectedSphere, | ||
attribute: newAttribute, | ||
}); | ||
if (ptCtx.mainViewInstance) { | ||
ptCtx.mainViewInstance?.generateSpheres(newSphereList); | ||
topViewSelectedChanged({ | ||
newSelectedSphere: selectedSphere, | ||
newSphereList: newSphereList, | ||
}); | ||
} | ||
} | ||
}; | ||
|
||
return { | ||
updatePointCloudAttribute, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters