-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(welcomeScreen): add custom story markers to globe (#448)
* feat(welcomeScreen): add story markers to globe * feat(welcomeScreen): add custom billboard entities * feat(welcomeScreen): remove comment * fix(layer-selector): change animation type back to lower case * feat(fonts): add NotesEsa font to markers * feat(markers): hide markers in layer selection * refactor(welcomeScreen): remove showMarker from store and pass markers to globe directly * refactor(welcomeScreen): add custom hook for story markers * refactor(welcomeScreen): change return
- Loading branch information
1 parent
af06cd3
commit ea297f4
Showing
13 changed files
with
329 additions
and
7 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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import {useEffect} from 'react'; | ||
import {useDispatch} from 'react-redux'; | ||
import {useHistory} from 'react-router-dom'; | ||
import { | ||
Viewer, | ||
ScreenSpaceEventHandler, | ||
defined, | ||
ScreenSpaceEventType | ||
} from 'cesium'; | ||
|
||
import {createMarker} from '../libs/create-marker'; | ||
|
||
import {Marker} from '../types/marker-type'; | ||
|
||
export const useMarkers = (viewer: Viewer | null, markers: Marker[]) => { | ||
const history = useHistory(); | ||
const dispatch = useDispatch(); | ||
|
||
// create marker for each story | ||
useEffect(() => { | ||
if (!viewer) { | ||
return; | ||
} | ||
|
||
const scene = viewer.scene; | ||
const handler = new ScreenSpaceEventHandler( | ||
scene.canvas as HTMLCanvasElement | ||
); | ||
|
||
handler.setInputAction(movement => { | ||
const pickedObject = scene.pick(movement.position); | ||
if (defined(pickedObject)) { | ||
history.push(`/stories/${pickedObject.id._id}/0`); | ||
} | ||
}, ScreenSpaceEventType.LEFT_CLICK); | ||
|
||
Promise.all(markers.map(marker => createMarker(marker))).then(entities => { | ||
viewer.entities.removeAll(); | ||
entities.forEach(entity => viewer.entities.add(entity)); | ||
}); | ||
|
||
// eslint-disable-next-line consistent-return | ||
return () => handler.destroy(); | ||
}, [dispatch, history, markers, viewer]); | ||
|
||
return; | ||
}; |
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,24 @@ | ||
import {useSelector} from 'react-redux'; | ||
|
||
import {selectedLayerIdsSelector} from '../selectors/layers/selected-ids'; | ||
import {StoriesStateSelector} from '../selectors/story/story-state'; | ||
|
||
export const useStoryMarkers = () => { | ||
const selectedLayers = useSelector(selectedLayerIdsSelector); | ||
const stories = useSelector(StoriesStateSelector).list; | ||
const hideMarkers = Boolean( | ||
selectedLayers.mainId || selectedLayers.compareId | ||
); | ||
|
||
if (hideMarkers) { | ||
return []; | ||
} | ||
|
||
const storyMarkers = stories.map(story => ({ | ||
id: story.id, | ||
title: story.title, | ||
position: story.position | ||
})); | ||
|
||
return storyMarkers; | ||
}; |
Oops, something went wrong.