12 minutes
Time of Day
Lesson 1.3 ended under the car. Floor it from the start line, and 100 m out the shadow is gone. That is 3.2 s into the drive.
The rest of the light is stuck as well. One sun hangs over the start line and never moves, and one sky photo lights the car and never changes. This lesson gives them a clock, stopped at 16:12. Lesson 1.8 sets it going.
The sun from the hour
The sun's height follows a wave. It rises at dawn, tops out at noon, sets at dusk and spends the night below the ground. One trip round the wave, 2π, takes 24 hours:
In the code it is one line:
That number is a height, not an angle: 0.454 is the sine of 27°. dayLightAt turns it into the light's direction, colour and strength, and the direction comes from these lines:
Continue reading
Unlock the Full Course
Every lesson, the runnable examples, and the finished build — yours to keep.