Skip to content

Commit

Permalink
fix(globe): check for cesium widget
Browse files Browse the repository at this point in the history
  • Loading branch information
KatvonRivia committed Jan 31, 2023
1 parent 0ee45ca commit 6618fc7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/scripts/components/main/globe/globe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ const Globe: FunctionComponent<Props> = ({
return () => {};
}

const setNewView = (newMode: number) => {
if (newMode === 2) {
const setNewView = (previousMode: number) => {
if (previousMode === 3) {
const newView = {
position: {
height: 40000000,
Expand All @@ -270,16 +270,18 @@ const Globe: FunctionComponent<Props> = ({
viewer.scene.morphTo2D(projectionState.morphTime);

// fixes projection being cut off after morphing to 2D
viewer.scene.morphComplete.addEventListener(
(ignore, previousMode, newMode) => setNewView(newMode)
viewer.scene.morphComplete.addEventListener(event =>
setNewView(event._previousMode)
);
} else {
viewer.scene.screenSpaceCameraController.maximumZoomDistance = 30000000;
viewer.scene.morphTo3D(projectionState.morphTime);
}

return () => {
viewer.scene.morphComplete.removeEventListener(setNewView);
if (viewer.cesiumWidget) {
viewer.scene.morphComplete.removeEventListener(setNewView);
}
};
}, [viewer, projectionState]);

Expand Down

0 comments on commit 6618fc7

Please sign in to comment.