How to use the token with olcesium

1. A concise explanation of the problem you're experiencing.

Can't reach to use token (Cesium ion) and the viewer properly with olcesium:
.without viewer and token, terrain is working fine but I have the message 'please assign....'
.with viewer and token, terrain isn't working (but no more 'please assign' message)
(TypeError: e is null[En savoir plus] Cesium.js:535:6460 )

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.

const scene = ol3d.getCesiumScene();

/*
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjZDZiOGQ1Zi1mZThlLTQ5MjJgtYmM2Ny0yZjM1ZTUyZWQ3NWIiLCJpZCI6NDEzMCwic2NvcGVzIjpbImFzciIsImdjIl0sImlhdCI6MTUzOTk1NjYzNn0.4WXr-J59gKgmSOTsiARppKyjarOo_c7zjg8CEBCaOxo';

var viewer = new Cesium.Viewer('cesiumContainer', {
    
    sceneModePicker : false,
    terrainProvider : Cesium.createWorldTerrain()
});*/

scene.terrainProvider = Cesium.createWorldTerrain({
    requestWaterMask: true,
    requestVertexNormals: true,

});

var globe = scene.globe;
scene.globe.enableLighting = true;

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

I use it with geoserver/openlayers(5.2) to improve the render

4. The Cesium version you're using, your operating system and browser.

Cesium Ion, windows 7 Pro, Firefox 63.0

I think you might not be initializing the map correctly. You have to set the token before the open layers initializes the viewer. I found this example helpful:

https://github.com/openlayers/ol-cesium/blob/master/examples/main.js

Let me know if that helps.

Thanks for the answer, if I do that when I switch to 3D, the logo cesium ion appears but the rest of the screen is black...

Échec du chargement pour l’élément <script> dont la source est « http://10.31.2.102/node_modules/@camptocamp/cesium/Build/Cesium/Cesium.js ».

I would check the console to see if there are any errors.

It also sounds like open layers might need to update their examples if it’s not working. It might worth posting on their community/GitHub as well.

Hi,

I dont see critical errors but anyway I will check on github and I just post an issue on it, thanks!