Cesium.Cartographic.fromDegrees is not a constructor

Until recently, this code was working for me. Now I am getting an error that Cesium.Cartographic.fromDegrees is not a constructor. Any help is appreciated

const position = Cesium.Cartographic.toCartesian(

new Cesium.Cartographic.fromDegrees(longitude, latitude, 0)

);

Hi @cadsmn289! The CesiumJS codebase is gradually migrating from an older JavaScript inheritance syntax, to the newer syntax of ES6 Classes. In general the migration should have no effect on your application code, but the example above is an exception — the new keyword must be used only when calling a constructor directly, and not when calling a factory method (like .fromDegrees(...)) which constructs and returns an instance internally.

// ✅ ok
const position = new Cesium.Cartographic(lon, lat);
const position = Cesium.Cartographic.fromDegrees(lonDeg, latDeg);

// ❌ error
const position = new Cesium.Cartographic.fromDegrees(lonDeg, latDeg);

The two “ok” examples above already worked before, so it’s safe to remove new here even if you’re not using a newer version of CesiumJS yet. If you’re using ESLint, you may also find the new-cap rule helpful to catch this issue automatically without waiting for runtime errors.

For more details, see: