Error 404 when terrain provider is set

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:

  1. Can you try using the default access token from Sandcastle and see if that works? (console.log(Cesium.Ion.defaultToken))
  2. 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()
});
  1. 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 :slight_smile:

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:

  1. Do you have it added under the My Assets tab in your ion account?
  2. If you have a token, can you double check the scopes on the token?
  3. Can you generate a new token and try to use that to load the asset? Does that work?

Hi,

  1. No, I don’t have Cesium World terrain under my assets. I only have Bing Maps Road,Bing maps Aerial, Bing Maps Aerial with labels + my own assets.

  2. My default access token has these scopes :

  • assets:read

  • geocode

  1. I did tried that, but does not work either.