Hello everyone, I am using cesium component in react.js. When I write the createTerrainAsync()
function, which came after version 1.107, into the terrainProvider prop as below, the world does not load. How can I use this asynchronous code. Thanks in advance
<Viewer
geocoder={false}
style={{ height: 'calc(100vh - 5rem)', width: '100vw' }}
navigationHelpButton={false}
key={viewerKey}
timeline={false}
terrainProvider={ loadTerrain()}
animation={false}
skyBox={false}
infoBox
fullscreenButton={false}
>
Hi,
Is this using CesiumJS directly or Resium? Resium is a third party maintained plugin, and they might need to do some updates based on the latest CesiumJS release, which deprecated a few old functions.
import { Viewer, KmlDataSource, CameraFlyTo } from 'resium';
import * as Cesium from 'cesium';
...
const loadCesiumTerrain = async () => {
const terrainProvider = await Cesium.createWorldTerrainAsync();
return terrainProvider;
};
useEffect(() => {
const fetchTerrain = async () => {
const terrain = await loadCesiumTerrain();
setTerrainProvider(terrain);
};
fetchTerrain();
...
return(
<Viewer
geocoder={false}
style={{ height: 'calc(100vh - 5rem)', width: '100vw' }}
navigationHelpButton={false}
key={viewerKey}
timeline={false}
terrainProvider={terrainProvider}
animation={false}
skyBox={false}
ref={viewerRef}
infoBox
requestRenderMode
maximumRenderTimeChange={Infinity}
fullscreenButton={false}
>
)
As in the example above, I use the functions from the Cesium library, but I get the components from the resium library.
Hi,
Does resium support setting the terrainProvider
prop after initialization? I would leave the prop initially undefined, then set the terrainProvider
prop after Cesium.createWorldTerrainAsync
has resolved.
my example code above was working but not working for the past few days. I am currently using cesium 1.107.2 and resium 1.17.1. When I read the changelog files, I couldn’t see any change. Can you share a sample code, thanks in advance
Hi,
The Cesium team does not officially support the resium project, and I’m not sure of all the details. I would suggest asking the project maintainers here.
Thanks!