Skip to content

Commit

Permalink
updated cesium preview to latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
tebben committed Sep 6, 2024
1 parent ddd42e8 commit b095944
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
10 changes: 5 additions & 5 deletions ctod/templates/preview/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<script type="module">
import { Pane } from "https://cdn.jsdelivr.net/npm/[email protected]/dist/tweakpane.min.js";
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/cesium/1.106.0/Cesium.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/cesium/1.121.1/Cesium.js"></script>
<script src="./scripts/utils.js"></script>
<script src="./scripts/index.js"></script>
<script src="./scripts/controls.js"></script>
<script src="./scripts/slopeshade.js"></script>
<link
href="https://cdnjs.cloudflare.com/ajax/libs/cesium/1.106.0/Widgets/widgets.min.css"
href="https://cdnjs.cloudflare.com/ajax/libs/cesium/1.121.1/Widgets/widgets.min.css"
rel="stylesheet"
/>

Expand Down Expand Up @@ -42,7 +42,8 @@
}

#attribution {
font-family: "Courier New", Courier, "Lucida Console", "Monaco", monospace;
font-family: "Courier New", Courier, "Lucida Console", "Monaco",
monospace;
position: absolute;
bottom: 0;
right: 0;
Expand All @@ -57,7 +58,6 @@
</head>
<body>
<div id="cesiumContainer"></div>
<div id="attribution">
</div>
<div id="attribution"></div>
</body>
</html>
26 changes: 14 additions & 12 deletions ctod/templates/preview/scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ var viewer,
currentCog,
dataset;

function loadCesium() {
async function loadCesium() {
Cesium.Ion.defaultAccessToken = undefined;

viewer = new Cesium.Viewer("cesiumContainer", {
imageryProvider: false,
baseLayer: false,
requestRenderMode: true,
timeline: false,
animation: false,
Expand All @@ -26,13 +26,13 @@ function loadCesium() {
msaaSamples: 1,
});

initializeLayers();
initTerrainProvider();
await initializeLayers();
await initTerrainProvider();
configureViewer();
setShading();
}

function initializeLayers() {
async function initializeLayers() {
streetsLayer = new Cesium.ImageryLayer(
new Cesium.OpenStreetMapImageryProvider({
url: "https://tile.openstreetmap.org/",
Expand Down Expand Up @@ -68,15 +68,15 @@ function initializeLayers() {
useStreetLayer();
}

function initTerrainProvider() {
async function initTerrainProvider() {
dataset = getUrlParamIgnoreCase("dataset") || undefined;
const minZoom = getUrlParamIgnoreCase("minZoom") || 1;
const maxZoom = getUrlParamIgnoreCase("maxZoom") || 18;
const noData = getUrlParamIgnoreCase("noData") || 0;
const cog = getUrlParamIgnoreCase("cog") || "./ctod/files/test_cog.tif";
const skipCache = getUrlParamIgnoreCase("skipCache") || false;
const meshingMethod = getUrlParamIgnoreCase("meshingMethod") || "grid";
setTerrainProvider(
await setTerrainProvider(
minZoom,
maxZoom,
noData,
Expand Down Expand Up @@ -124,7 +124,7 @@ function configureViewer() {
});
}

function setTerrainProvider(
async function setTerrainProvider(
minZoom,
maxZoom,
noData,
Expand All @@ -145,10 +145,12 @@ function setTerrainProvider(
}
}

terrainProvider = new Cesium.CesiumTerrainProvider({
url: terrainProviderUrl,
requestVertexNormals: true,
});
terrainProvider = await Cesium.CesiumTerrainProvider.fromUrl(
terrainProviderUrl,
{
requestVertexNormals: true,
}
);

viewer.terrainProvider = terrainProvider;
if (currentCog !== cog) {
Expand Down

0 comments on commit b095944

Please sign in to comment.