Missing functionality when Cesium is loaded with the file protocol


I am working on a proposal to use Cesium embedded as a globe viewer in an application. I would like to avoid deploying a web server along with the application, so I searched in the forum, in google and the documentation all that could help understand how to use Cesium without a web server. I partially succeeded, but the following problem is blocking any progress.

I am using Cesium 1.30 viewer in a browser control (QWebEngineView) and it works fine, as long as the html page with the Cesium viewer is accessed through a (local) web server. However, if I load the html with the file protocol, some things stop working, such as the Animation widget (the displayed clock is stopped) or viewer.flyTo (the camera won’t move when loading KML files). Using a browser such as Chrome (with the --disable-web-security or --allow-file-access-from-files options) it happens exactly the same.

After some debugging I found that the problem is in the returned status code of XMLHttpRequest, which is 0 when using the file protocol (no http status code) causing loadWithXhr.load to fail, even when the response has the correct data (for instance, ‘Assets/approximateTerrainHeights.json’, used in the initialization of GroundPrimitive). If I change loadWithXhr.load to accept a status of 0, everything works ok again. But, of course, changing Cesium.js code is not a solution.

I am new to both JavaScript and Cesium, so my question is if I’m trying to do something that cannot be done, or if I am missing some important point, or both.

Thanks for any help,


Hello Fernando,

I think Cesium needs to be run using a local web server. There are security constraints that prevent the browser from accessing files from your local file system in that way.



Hi Hannah,

Thanks for your quick reply. From some posts in the forum and in StackOverflow, I thought this was a possible way to use Cesium (maybe with some restrictions, but somewhat supported, nevertheless). For instance: http://stackoverflow.com/questions/31428956/run-cesiumjs-with-no-server-requirements/31432464#31432464

Our context is an open-source Qt GIS application, and we’ve been experimenting with an embedded browser window to, for instance, show some KML files it generates with satellite tracks and data.

In what concerns “our” files (the KML files), the browser can access the local file system in a standard way (with the usual restrictions) or the Qt application itself can read the files and provide the KML content to the Cesium viewer in the browser widget. I successfully did it following the “basic KML parse” from the “KML Examples” in http://cesiumjs.org/2015/05/07/New-KML-Examples/ (as explained in the previous post, when not using the web server this only worked by changing Cesium.js to accept a XmlHttpRequest status 0).

But, of course, the way Cesium itself needs to access local files, namely its own resources such as the Assets folder, is a different matter, and I don’t know enough to understand if it is reasonable to make the suggestion for this possibility to be supported. It would be very welcome, however, to be able to use Cesium in a desktop application and at the same time deploy it in the user’s machines without installing also an additional web server, even a light one.

Thank you very much anyway, and best regards,


segunda-feira, 27 de Fevereiro de 2017 às 14:38:18 UTC, Hannah Pinkos escreveu:

Hi Fernando,

For using Cesium in a desktop application, check out this blog post about using electron: http://cesiumjs.org/2016/04/04/An-Introduction-to-Cesium-Desktop-Apps-with-Electron/

That might be helpful for you.


Hi Hannah,

Thanks for your suggestion. I will check it for sure.



segunda-feira, 27 de Fevereiro de 2017 às 18:14:56 UTC, Hannah Pinkos escreveu: