Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
fix: Cesium flashes on camera change (#257)
Browse files Browse the repository at this point in the history
Co-authored-by: rot1024 <aayhrot@gmail.com>
  • Loading branch information
airslice and rot1024 authored Jun 23, 2022
1 parent 19fcb69 commit ad2c0e3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export default function ({ isSelected, camera }: { isSelected?: boolean; camera?
const fov = prevCamera.current?.fov ?? defaultFOV;
flyTo?.({ fov }, { duration: 0 });
}
// skip camera flight when selected layer was changed by storytelling widget
startTransition(!isSelected, storytelling.current ? !isSelected : !cameraRef.current);
// skip camera flight when is not selected
startTransition(!isSelected, !isSelected);
}, [flyTo, startTransition, isSelected]);

const transition = useTransition(
Expand Down
10 changes: 0 additions & 10 deletions src/components/molecules/Visualizer/Engine/Cesium/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,12 @@ export default ({
}, []);

// call onCameraChange event after moving camera
const emittedCamera = useRef<Camera>();
const updateCamera = useCallback(() => {
const viewer = cesium?.current?.cesiumElement;
if (!viewer || viewer.isDestroyed() || !onCameraChange) return;

const c = getCamera(viewer);
if (c && !isEqual(c, camera)) {
emittedCamera.current = c;
onCameraChange?.(c);
}
}, [camera, onCameraChange]);
Expand All @@ -192,14 +190,6 @@ export default ({
updateCamera();
}, [updateCamera]);

// camera
useEffect(() => {
if (camera && (!emittedCamera.current || emittedCamera.current !== camera)) {
engineAPI.flyTo(camera, { duration: 0 });
emittedCamera.current = undefined;
}
}, [camera, engineAPI]);

// manage layer selection
useEffect(() => {
const viewer = cesium.current?.cesiumElement;
Expand Down

0 comments on commit ad2c0e3

Please sign in to comment.