Hi everyone,
I’m trying to add a terrain with elevations in my web application based on CesiumJS and Resium :
<Viewer
style={{ position: "absolute", width: '100%', height: '100%', top: 0, left: 0 }}
ref={refViewer}
baseLayerPicker={false}
timeline={false}
animation={false}
navigationHelpButton={false}
sceneModePicker={false}
terrainProvider={createWorldTerrainAsync({})}
>
However, it returns errors 404, and the cesium viewer crashes :
“{“code”:“ResourceNotFound”,“message”:“Resource Not Found: /v1/assets/1/endpoint?access_token=<my_token>&assetRegion=us-east-1”}”
Without the terrainprovider, it is working, but the terrain is flat. Ion.defaultAccessToken is defined, and the scopes are assets:read, geocode
I don’t understand why it does not work. If it is wrong to set a terrain provider this way, how should I do it?
Thanks for your help.
Hi @Denis.Biguenet
I’m not exactly sure what the issue is, but here are a few steps that might help us figure out what’s going on:
- Can you try using the default access token from Sandcastle and see if that works? (
console.log(Cesium.Ion.defaultToken))
- I’m not super familiar with Resium, but try loading it the JS way to see if it produces the same error:
const viewer = new Cesium.Viewer("cesiumContainer", {
terrainProvider: await Cesium.createWorldTerrainAsync()
});
- Also,
createWorldTerrainAsync is async (as it’s name suggests), so you’re really passing terrainProvider a Promise<Terrain>, not the terrain itself. You should await it (I don’t know if react components allow await inside the tag, might have to do something like:)
const [terrain, setTerrain] = useState();
useEffect(() => {
Cesium.createWorldTerrainAsync().then(setTerrain);
}, []);
<Viewer terrainProvider={terrain} />
Hi mzschwartz5
Thanks for your response, I have something new about this issue.
It is definitely an access token issue : I was able to find another token we were using in cesium examples last year, and it works without changing the code from my first message.
Besides, I don’t see asset 1 in my assets. 2, 3 and 4 are there, but not 1, which could explain why my personal token does not have access to world terrain? I’m logging using my Bentley employee account.
I see - in that case, I’m going to move this thread into the Cesium Ion category. The Ion folks will be much more helpful for this sort of problem 
1 Like
H,
I apologize if I misunderstood anything in this thread and correct me if that is the case. If you are unable to load Cesium World Terrain, can you verify a couple of things for me:
- Do you have it added under the
My Assets tab in your ion account?
- If you have a token, can you double check the scopes on the token?
- Can you generate a new token and try to use that to load the asset? Does that work?