3D coordinates, height and local frames
Quick answer
This tutorial maps the three coordinate representations CesiumJS mixes: Cartographic in radians and metres, Cartesian3 in ECEF metres, and local east-north-up frames. It shows Cartographic.fromDegrees, Cartesian3.fromRadians, Cartesian3.fromDegreesArray and Transforms.eastNorthUpToFixedFrame with Matrix4 multiplication. It also explains heightReference values, globe.getHeight, pickEllipsoid versus pickPosition and cartesianToCanvasCoordinates. Readers can convert between all forms and place models or labels without drift.
Key points
- Cartographic stores longitude and latitude in radians but height in metres; never feed radians back into fromDegrees.
- Set heightReference to CLAMP_TO_GROUND or RELATIVE_TO_GROUND so entities follow loaded terrain.
- Build a local frame with eastNorthUpToFixedFrame and transform points through Matrix4.multiplyByPoint.
Example
var carto = Cesium.Cartographic.fromDegrees(116.391263, 39.907359, 50);
console.log(carto.longitude); // 2.0313...
console.log(carto.latitude); // 0.6965...
console.log(carto.height); // 50
var cartesian = Cesium.Cartesian3.fromRadians(
carto.longitude, carto.latitude, carto.height
);
var back = Cesium.Cartographic.fromCartesian(cartesian, Cesium.Ellipsoid.WGS84);
var positions = Cesium.Cartesian3.fromDegreesArray([
116.391, 39.907,
116.404, 39.915,
116.418, 39.921
]);viewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(116.391263, 39.907359),
point: {
pixelSize: 10,
color: Cesium.Color.fromCssColorString('#4d9bff'),
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND
},
label: {
text: '地面点',
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
disableDepthTestDistance: Number.POSITIVE_INFINITY
}
});
var carto = Cesium.Cartographic.fromDegrees(116.391263, 39.907359);
var ground = viewer.scene.globe.getHeight(carto); // 地形未加载完时返回 undefined
Notes
- Passing degrees where radians are expected throws coordinates to the opposite side of the globe.
- globe.getHeight returns undefined until the terrain tile for that location has loaded.
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Atlaslog (2026). 3D coordinates, height and local frames. https://www.jingweizhi.com/en/cesium/tutorials/coordinates.html (accessed 2026-11-03).