Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how CESIUM_BASE_URL works and when to use it #8327

Closed
OmarShehata opened this issue Oct 28, 2019 · 4 comments
Closed

Document how CESIUM_BASE_URL works and when to use it #8327

OmarShehata opened this issue Oct 28, 2019 · 4 comments

Comments

@OmarShehata
Copy link
Contributor

From the discussion in #8314 (comment), if you're importing CesiumJS into your project as a module (so if you're not just including Cesium.js as a script tag), then you may need to set the CESIUM_BASE_URL as a global variable on the window object so that CesiumJS knows where to load assets like the worker scripts.

We should:

  1. Improve the error message you get when this needs to be set. Currently it just says Unable to determine Cesium base URL automatically, try defining a global variable called CESIUM_BASE_URL. but that doesn't tell you what the content of this global variable should be.

  2. Consider writing up a paragraph somewhere we can reference that explains why this needs to be set, which would be helpful for users trying to import CesiumJS in whatever module system or environment they happen to be using. ThreeJS has a nice section in their docs about the different ways you can import the library.

@rmckeel
Copy link

rmckeel commented Dec 13, 2019

@OmarShehata Great points, thank you. One thing that seems to be missing from https://cesium.com/blog/2019/10/31/cesiumjs-es6/ and documentation is related to this. Say I set the base URL as below:

    // simple passthrough of current href to CESIUM_BASE_URL
    (window as any).CESIUM_BASE_URL = window.location.href

I now get 404 not found on http://my.url/Assets/approximateTerrainHeights.json and
http://my.url/Assets/IAU2006_XYS/IAU2006_XYS_16.json.

It is not clear to me what I need to do here - copy files? Import assets into the ES6 code area that is using them? I have not ejected my React app where this is loaded, so I do not have much in the way of webpack flexibility.

Thanks for any insight, or at the minimum consideration of these concerns in documentation.

@OmarShehata
Copy link
Contributor Author

@rmckeel the Assets folder contains a few things the CesiumJS library needs, like the icons for the widgets, the default skybox, etc. What you'd need to do is to statically serve that directory. So you can move the Assets/ folder outside of the build folder and put it wherever you have files served statically in your app.

@rmckeel
Copy link

rmckeel commented Dec 13, 2019

@OmarShehata Good to know, I'll do that. I wonder how often those files will change, e.g. if I bump the version in package I'd likely need a developer to re-copy that. What'd be nice is a way to import/extract that automatically, but without ejecting React/Angular/etc, not sure the best way to do that.

Thanks for your comment! That's the tree I was starting to bark up to copy assets to a public directory.

@OmarShehata
Copy link
Contributor Author

This is now documented in our new quickstart guide: https://cesium.com/docs/tutorials/quick-start/#step-2-set-up-the-cesiumjs-client

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants