Cast a ray from the Moon in the direction of the Sun.
If that ray intersects the Earth, it might be an eclipse.
What I find neat is that Earth’s rotation (once every 24 hours) is completely decoupled from the Sun-Earth-Moon’s orbits. Yet, the simulated eclipses are pretty close to professional estimates.
In case you do, you could add a fast forward mode to next eclipse (or fast rewind to previous), and once there turn into slow motion. Also, the moon’s shadow casted on the earth surface would be a nice touch.
Great ideas! I’m sure the next eclipse could be found with a while loop and the shadow would be great! Wonder if I would try it in shader code or with threejs lights
Added the suggestions! But now that I have pause, backward, and forward buttons, I’m a bit worried I might be introducing some bugs. ¯_(ツ)_/¯
Also calling the raycaster, while intersecting, was causing slowdowns (understandably, it was called 5000 times per animation frame). Since I’m only casting to a perfect sphere (earth), I wrote a custom raycaster that seems a bit faster!
For this physics model, I need a small time step and check for eclipses (intersections) at every step. Since it uses real space data, when simulating over months or years, it progresses using a dt of only a few minutes in size