Terrain loading problem Cesium world terrain

It seems basic and of all the tutorials, none of the exact lines work as intended. I can’t get World Terrain to render in a custom application. The difference of one line of code (to set it initially in Viewer or not) renders a white screen instead of the globe. I am able to stream Bing imagery so I don’t think it’s a firewall setting. It throws the error also attached. Looking for suggestions. The “setTerrain” function generates a similar error.

Hi @tstritch1,
Thank you for your post and being a part of the Cesium community.

Sorry to hear you are having trouble loading Cesium World Terrain into your application. The error message you tried to post is partially obscured, can you post a full version (posting a screenshot image or copy/pasting the text is fine)?

Seeing the error should help us narrow down the origin of the issue you are experiencing.

Thanks,
Luke

Cesium_errorMessage

Uncaught TypeError: Cannot read properties of undefined (reading ‘fromWorldTerrain’)
at GlobalVariables.js:398:29

Thanks for sharing, @tstritch1 .
It sounds like your issues may be due to project setup and imports.
What is the general set up of you project in terms of package manager, build tooling, etc? Are you using tools like for example webpack, Vite, etc or other ? That should help us further narrow down and get you the help resources you need.
Thanks,
Luke

It’s a pretty Vanilla setup which is part of why I can’t figure out what is wrong. I’m not using any tools, just have the cesium directory in a project one directory parallel to my html file.

Here’s the code to run the server:

import http.server
from http.server import HTTPServer,SimpleHTTPRequestHandler
import ssl
shttprhd=SimpleHTTPRequestHandler
shttprhd.extensions_map={
    '.manifest': 'text/cache-manifest',
    '.html': 'text/html',
    '.png': 'image/png',
    '.jpg': 'image/jpg',
    '.crn': 'image/crn',
    '.ktx': 'image/ktx',
    '.css': 'text/css',
    '.glsl':'text/plain',
    '.js': 'application/javascript',
    '.json': 'application/json',
    '.czml': 'application/json',
    '.geojson': 'application/json',
    '.topojson': 'application/json',
    '.wasm': 'application/wasm',
    '.xml': 'application/xml',
    '.b3dm': 'application/octet-stream',
    '.pnts': 'application/octet-stream',
    '.i3dm': 'application/octet-stream',
    '.cmpt': 'application/octet-stream',
    '.geom': 'application/octet-stream',
    '.vctr': 'application/octet-stream',
    '.gltf': 'model/gltf+json',
    '.bgltf': 'model/gltf-binary',
    '.glb': 'model/gltf-binary',
    '':'application/javascript'
}

httpd= HTTPServer(('localhost',8280),shttprhd)
# httpd.socket= ssl.wrap_socket(httpd.socket,certfile='./server.pem',server_side=True)
httpd.serve_forever()

And the code to launch the browser and html:

@start /max /w chrome "http://localhost:8280/hwil/hwil_live.html?server=localhost"

And an image of the code structure in VSCode

Hi @tstritch1 ,
Before we take a look at what you provided, can you also share what version of Cesium you are using? If you are on an older version there may have been breaking api changes.

Thanks,
Luke

Looks like 1.101.0. I can update if we think that’s the issue.

1.101.0 is almost 2 years old, so it’s highly likely upgrading will fix the issue.

Well the update definitely helped but I have some different weird behavior now. It stopped loading the imagery. Is that something that might have updated? I don’t get an error message like I did previously for the terrain I just see this:

I think the terrain is loaded and hard to tell because the imagery isn’t on top of it.

Hi @tstritch1 ,

There have been some breaking api changes since 1.101.0 which will require updating your code.

Looking at the file you shared in your original post, I see you are passing the imageryProvider option to Viewer. This was depreciated in the 1.107.0 release so now you should use baseLayer instead. cesium/CHANGES.md at main · CesiumGS/cesium · GitHub

That is the main issue I see in your code with respect to api changes in newer version of Cesium. Any additional deprecations to the public API will also be listed in the CHANGES.md file linked above.

Hope that helps and please let us know if you have further questions.
Best,
Luke

Great, that worked. It’s a little confusing since the tutorials haven’t been updated but I suppose there are more of those than are easy to modify every time the API is changed. Thanks for your help!