Having hacked together a way to switch cameras in Gladius, I am ready to try to better position one of those cameras. In my solar system simulation, my view of Earth's night sky is not sufficient to witness retrograde motion of Mars:
To better see this, I need to point my "Earth Camera" not directly at the night sky (i.e. away from the Sun), but at Mars.
Since I am already calculating the absolute (i.e. not relative to anything else) position of both Mars and the Earth, I can position the camera absolutely as well:
Earth is actually at z=20, so by positioning the camera at z=19.5, I am viewing from slightly above the earth.
space. findNamed("camera2"). findComponent("Transform"). setPosition([earthX, earthY, 19.5]);
Similarly, since I am already calculating the angle between the Earth and Mars (to draw the line of sight marker), I can use this to rotate the camera to fixate on Mars:
With that, I can finally witness a decent retrograde motion from Earth.
space. findNamed("camera2"). findComponent("Transform"). setRotation([3*Math.PI/2, 0, Math.PI -angle]);
Mars normally moves to the left (eastward):
But, when the Earth passes it in its orbit, it seems to shift back:
I had hoped to be able to fix the camera to the Earth's frame of reference—the position could then be (0, 0, -1) or something similarly easy. Unfortunately computing the proper angles given the Earth's frame of reference and the actual angle between Earth and Mars proved too challenging for me.
It would also be nice to be able to make use of
lookAt()in CubicVR.js. I may give that a try another night. For now, I am just happy to actually have retrograde motion showing.