The track is a randomly generate set of points going into the distance
Catmull-Rom splines are used for interpolation
Catmull-Rom splines use 4 points to interpolate between 2. This keeps the track smooth, but it means that we need an extra point before the track starts and one after the end. That's why you don't go all the way to the last triangle before restarting at the beginning
I'm not actually Z-buffering here. With reasonable confidence, I know the order ahead of time (ground is far away, the death star is far away, and the spline is (almost) z-sorted by construction) so I just paint back to front. This means some things would be more complex to implement
The engine isn't particularly general-purpose. Ideally, it would accept a tree of objects, each with their own transformation matricies. Unfortunately, due to the lack of z-buffering, every type of object has its own requirements for proper painting (for example, the TIE fighter is painted in one of three different ways depending on how you're looking at it). I may eventually generalize it a bit more and use wireframe drawing....
The line fades as it gets close to you. The fade of a segment is determined by the distance to part of that segment rather than the time it'll take to reach that segment. This means that around sharp turns, it's possible for part of the line that you won't actually reach for a while will be faded. Since the same logic is used to clip the spline, semgents could potentially disappear too early.
I'm fairly sure there is still at least one bug - I've noticed occasional flickering of the ground, and occasional oddly-warped triangles. If I happen to figure out when exactly the issues occur, I might try to fix it
The diagonal line on the ground arises from anitaliasing.
Painting the ground is incredibly expensive. I'm not entirely sure why - maybe I'm still asking canvas to paint a lot of offscreen garbage when I clip the triangles or something.
Canvas apparently uses 16-bit coordinates. This causes ugliness if pixel positions get too big. It may also cause your browser (or, on *nix, your X server) to gobble HUGE amounts of RAM sometimes. Don't set the scale to be too big.