-
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(cesium): add first cesium globe (#80)
* feat(cesium): add first cesium steps * feat(cesium): use pre-build cesium * feat(cesium): copy assets * feat(cesium): load in component
- Loading branch information
Showing
8 changed files
with
270 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = true |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,2 +1,6 @@ | ||
.app | ||
border: 1px solid green | ||
:global(html), :global(body), :global(#app) | ||
margin: 0 | ||
height: 100% | ||
|
||
.app | ||
height: 100% |
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,2 @@ | ||
.globe | ||
height: 100% |
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,43 @@ | ||
import React, {FunctionComponent, useRef, useEffect, useState} from 'react'; | ||
|
||
import 'cesium/Source/Widgets/widgets.css'; | ||
import 'cesium/Build/Cesium/Cesium'; | ||
|
||
import styles from './globe.styl'; | ||
|
||
// set global base url | ||
const Cesium = window.Cesium; | ||
Cesium.buildModuleUrl.setBaseUrl('./cesium/'); | ||
|
||
const viewerOptions = { | ||
homeButton: false, | ||
fullscreenButton: false, | ||
sceneModePicker: false, | ||
infoBox: false, | ||
geocoder: false, | ||
navigationHelpButton: false, | ||
animation: false, | ||
timeline: false, | ||
baseLayerPicker: false | ||
}; | ||
|
||
const Globe: FunctionComponent<{}> = () => { | ||
const ref = useRef(); | ||
const [viewer, setViewer] = useState(null); | ||
|
||
useEffect(() => { | ||
if (!ref || !ref.current) { | ||
return; | ||
} | ||
|
||
const viewer = new Cesium.Viewer(ref.current, viewerOptions); | ||
return () => { | ||
viewer.destroy(); | ||
setViewer(null); | ||
}; | ||
}, [ref]); | ||
|
||
return <div className={styles.globe} ref={ref} />; | ||
}; | ||
|
||
export default Globe; |
Oops, something went wrong.