-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(welcomeScreen): add custom story markers to globe #448
Merged
Merged
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
374f137
feat(welcomeScreen): add story markers to globe
KatvonRivia 124d711
feat(welcomeScreen): add custom billboard entities
KatvonRivia d0afe95
Merge branch 'develop' into feat/welcomeScreen
KatvonRivia b3571ba
feat(welcomeScreen): remove comment
KatvonRivia 203e3fe
fix(layer-selector): change animation type back to lower case
KatvonRivia db40ea0
Merge branch 'develop' into feat/welcomeScreen
KatvonRivia 52041a0
feat(fonts): add NotesEsa font to markers
KatvonRivia ecb0cd3
feat(markers): hide markers in layer selection
KatvonRivia 5b41f44
refactor(welcomeScreen): remove showMarker from store and pass marker…
KatvonRivia a6b1262
Merge branch 'develop' into feat/welcomeScreen
KatvonRivia e3b0c37
refactor(welcomeScreen): add custom hook for story markers
KatvonRivia 7f02aee
Merge branch 'develop' into feat/welcomeScreen
KatvonRivia a26eec7
Merge branch 'develop' into feat/welcomeScreen
KatvonRivia dc16da2
refactor(welcomeScreen): change return
KatvonRivia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export const SHOW_MARKERS = 'SHOW_MARKERS'; | ||
|
||
export interface ShowMarkersAction { | ||
type: typeof SHOW_MARKERS; | ||
showMarkers: boolean; | ||
} | ||
|
||
const showMarkersAction = (showMarkers: boolean): ShowMarkersAction => ({ | ||
type: SHOW_MARKERS, | ||
showMarkers | ||
}); | ||
|
||
export default showMarkersAction; |
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,59 @@ | ||
import {useEffect} from 'react'; | ||
import {useSelector, useDispatch} from 'react-redux'; | ||
import {useHistory} from 'react-router-dom'; | ||
import { | ||
Viewer, | ||
ScreenSpaceEventHandler, | ||
defined, | ||
ScreenSpaceEventType | ||
} from 'cesium'; | ||
|
||
import {createMarker} from '../libs/create-markers'; | ||
import {showMarkersSelector} from '../selectors/show-markers'; | ||
import showMarkersAction from '../actions/show-markers'; | ||
|
||
import {StoryList} from '../types/story-list'; | ||
|
||
export const useMarkers = (viewer: Viewer | null, stories: StoryList) => { | ||
const showMarkers = useSelector(showMarkersSelector); | ||
const history = useHistory(); | ||
const dispatch = useDispatch(); | ||
|
||
// create marker for each story | ||
useEffect(() => { | ||
if (!viewer) { | ||
return; | ||
} | ||
|
||
viewer.entities.removeAll(); | ||
|
||
const scene = viewer.scene; | ||
const handler = new ScreenSpaceEventHandler( | ||
scene.canvas as HTMLCanvasElement | ||
); | ||
|
||
handler.setInputAction(movement => { | ||
const pickedObject = scene.pick(movement.position); | ||
if (defined(pickedObject)) { | ||
dispatch(showMarkersAction(false)); | ||
history.push(`/stories/${pickedObject.id._id}/0`); | ||
} | ||
}, ScreenSpaceEventType.LEFT_CLICK); | ||
|
||
const markers = showMarkers | ||
? stories.map(story => createMarker(story)) | ||
: []; | ||
|
||
Promise.all(markers) | ||
KatvonRivia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
.then((entities: Array<any>) => { | ||
entities.forEach(entity => viewer.entities.add(entity)); | ||
}) | ||
.catch(error => console.error(error)); | ||
|
||
// eslint-disable-next-line consistent-return | ||
return () => handler.destroy(); | ||
}, [showMarkers, dispatch, history, stories, viewer]); | ||
|
||
return; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we still need this here? we only use the bold font in the markers which load the font by themselves, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this the global font import for all components? We use both fonts in other components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry i mean: you're right we don't use is yet 😄 But we need it at least for the splash screen title. I have used the regular one before, but that's not correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah I see 👍