CesiumJS does properly simulatr both Sun and Moon positions in realtime, but for some reasons they are apparently not directly accessible: Moon object is just an ellipsoid, placed “somewhere”.
- How to know the cartesian coordinates of this somewhere?
- How to look at this point?
- How to draw a line from observer to this point?
I tested several sources from stackoverflow and cesium community, but they all sparse, approximate, buggy…
I even found an undocumented lookAtMoon() function in MoonSpec.js file, but I can’t figure out how to access it!
function lookAtMoon(camera, date) {
const icrfToFixed = new Matrix3();
if (!defined(Transforms.computeIcrfToFixedMatrix(date, icrfToFixed))) {
Transforms.computeTemeToPseudoFixedMatrix(date, icrfToFixed);
}
const moonPosition = Simon1994PlanetaryPositions.computeMoonPositionInEarthInertialFrame(
date
);
Matrix3.multiplyByVector(icrfToFixed, moonPosition, moonPosition);
camera.viewBoundingSphere(
new BoundingSphere(moonPosition, Ellipsoid.MOON.maximumRadius)
);
}