Skip to content

Commit

Permalink
fix cutplane toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegMoshkovich committed Oct 21, 2023
1 parent 7265afd commit 5714f17
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Components/CutPlaneMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ export default function CutPlaneMenu() {
const location = useLocation()
const open = Boolean(anchorEl)
const theme = useTheme()
const [isCutplane, setIsCutPlane] = useState(false)

debug().log('CutPlaneMenu: location: ', location)
debug().log('CutPlaneMenu: cutPlanes: ', cutPlanes)


const handleClick = (event) => {
setAnchorEl(event.currentTarget)
}
Expand All @@ -56,6 +56,7 @@ export default function CutPlaneMenu() {
const planes = getPlanes(planeHash)
debug().log('CutPlaneMenu#useEffect: planes: ', planes)
if (planes && planes.length) {
setIsCutPlane(true)
planes.forEach((plane) => {
togglePlane(plane)
})
Expand All @@ -81,6 +82,7 @@ export default function CutPlaneMenu() {
removeCutPlaneDirection(direction)
viewer.clipper.deleteAllPlanes()
const restCutPlanes = cutPlanes.filter((cutPlane) => cutPlane.direction !== direction)
setIsCutPlane(false)
restCutPlanes.forEach((restCutPlane) => {
const planeInfo = getPlaneSceneInfo({modelCenter, direction: restCutPlane.direction, offset: restCutPlane.offset})
viewer.clipper.createFromNormalAndCoplanarPoint(planeInfo.normal, planeInfo.modelCenterOffset)
Expand All @@ -102,7 +104,7 @@ export default function CutPlaneMenu() {
variant='solid'
icon={<CropOutlinedIcon className='icon-share' color='secondary'/>}
onClick={handleClick}
selected={anchorEl !== null || !!cutPlanes.length}
selected={anchorEl !== null || !!cutPlanes.length || isCutplane}
/>
<Menu
elevation={1}
Expand Down

0 comments on commit 5714f17

Please sign in to comment.