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

Regression: sampleTerrain no longer works in NodeJS #9906

Closed
bkuster opened this issue Nov 1, 2021 · 4 comments · Fixed by #10399
Closed

Regression: sampleTerrain no longer works in NodeJS #9906

bkuster opened this issue Nov 1, 2021 · 4 comments · Fixed by #10399

Comments

@bkuster
Copy link
Contributor

bkuster commented Nov 1, 2021

Issue

sampleTerrainMostDetailed no longer works. Error received: require is not defined.

Reasoning

require is no longer defined within an ESM module.

Reproducable

import { CesiumTerrainProvider, Cartographic, sampleTerrainMostDetailed } from "cesium";

const provider = new CesiumTerrainProvider({ url: 'https://berlin.virtualcitymap.de/datasource-data/5d2c8614-d474-442d-8975-c2b4a4c0ae94/' });
sampleTerrainMostDetailed(provider, [Cartographic.fromDegrees(0, 0)])
  .then((updated) => {
    console.log(updated);
  })
  .otherwise((err) => {
    console.error(err);
  });

Fix/Workaround

Use deferred import statements, as can be seen in this commit: virtualcitySYSTEMS@25f59d6

The question is, if cesium can support this for all its platforms? If so, I'm happy to open a PR.

@hpinkos
Copy link
Contributor

hpinkos commented Nov 1, 2021

Thanks for reporting this @bkuster! @ebogo1 we should look at this ASAP since it's a regression

@ebogo1
Copy link
Contributor

ebogo1 commented Nov 1, 2021

@bkuster I am able to reproduce this issue in CesiumJS 1.73 on Node 14 and 16. Which versions of CesiumJS and Node did you notice this regression in?

@bkuster
Copy link
Contributor Author

bkuster commented Nov 1, 2021

@ebogo1 I just stumbled across this issue today using Node 12 and cesium 1.79 (but I would assume the regression is older) while updating my module to ESM. I could also reproduce it in Node 14 & 16 (using 1.79). To verify, I then created a new package with the above code and used the latest cesium from npm & Node 14.

@ebogo1
Copy link
Contributor

ebogo1 commented Feb 8, 2022

I don't believe there's a workaround without revisiting how we package CesiumJS for Node - this issue will happen with any file that happens to call loadWithHttpRequest in Resource.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Issue/PR closed
Development

Successfully merging a pull request may close this issue.

4 participants