Skip to content

Commit

Permalink
Merge branch 'globe-enhancements' into ssr
Browse files Browse the repository at this point in the history
* globe-enhancements:
  Basic link to google earth
  Updated screen space errors
  • Loading branch information
davenquinn committed Oct 3, 2023
2 parents d98eaee + 86796f2 commit b484679
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion deps/cesium-viewer
Submodule cesium-viewer updated 2 files
+3 −3 src/index.ts
+45 −21 src/viewer.ts
19 changes: 12 additions & 7 deletions packages/globe-dev/src/cesium-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ import { MapboxImageryProvider } from "cesium";
// return h(ImageryLayer, { imageryProvider: provider.current, ...rest });
// }

function buildSatelliteLayer({ accessToken }) {
const provider = new MapboxImageryProvider({
mapId: "mapbox.satellite",
maximumLevel: 19,
accessToken,
});
return provider;
}

const SatelliteLayer = (props) => {
const { accessToken, ...rest } = props;
let satellite = useRef(
new MapboxImageryProvider({
mapId: "mapbox.satellite",
maximumLevel: 19,
accessToken,
})
);
let satellite = useRef(buildSatelliteLayer({ accessToken }));

return h(ImageryLayer, { imageryProvider: satellite.current, ...rest });
};
Expand All @@ -54,6 +57,8 @@ function CesiumView({ style, accessToken, ...rest }) {
{
terrainProvider: terrainProvider.current,
displayQuality: DisplayQuality.High,
fogDensity: 0.0002,
//skyBox: true,
showInspector: true,
showIonLogo: false,
...rest,
Expand Down
18 changes: 18 additions & 0 deletions packages/globe-dev/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,23 @@ function getStartingPosition(): MapPosition {

const _CesiumView = memo(CesiumView);

function GoogleEarthLink({ position }) {
const base = "https://earth.google.com/web/";
const { camera, target } = position;
const { altitude, pitch, bearing, azimuth } = camera;
let url = base;
if (target == null) {
url += `@${camera.lat},${camera.lng},${
altitude * 100
}d,${bearing}h,${pitch}t`;
} else {
const { lat, lng, distance } = target;
url += `@${lat},${lng},${distance}d,${bearing}h,${pitch}t`;
}

return h("a", { href: url, target: "_blank" }, "Open in Google Earth");
}

function App({ accessToken }) {
const initialPosition = useRef<MapPosition>(getStartingPosition());

Expand Down Expand Up @@ -118,6 +135,7 @@ function App({ accessToken }) {
setShown: setShowMapbox,
}),
h(Link, { href: mapURL }, "Switch to map"),
h(GoogleEarthLink, { position }, "Open in Google Earth"),
]),
]),
h("div.map-container", [
Expand Down
2 changes: 1 addition & 1 deletion packages/globe-dev/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var opts = {
// Makes cesium not render high fps all the time
requestRenderMode: true,
// Use full scene buffer (respecting pixel ratio) if this is false
useBrowserRecommendedResolution: false,
//useBrowserRecommendedResolution: false,
// We have a bug in the tile bounding box calculation somewhere.
terrainExaggeration: 1.0,
baseLayer: new Cesium.ImageryLayer(satellite),
Expand Down

0 comments on commit b484679

Please sign in to comment.