Simulating actual Sun position

I need to program a simple sky map (no stars, no nothing, just the sun and the sky color) with current geo loc and time of the user (basically to generate a credible sky tone given the time of the day). A simple color or gradient would be ok (or even a sphere that I could move in my phone as in those AR sky map apps). Any ideas or suggestions to go in a direction with this?
I started in pure JS (just getting the GPS values, time, calculating position of the sun, etc) but maybe three.js could help me to achieve a good graphical response in a easier way.

Thanks for any hint, and excuse the shameless question without putting any code.

I personally use the skydome (and hemisphere light) from this example:

I also have a directional light orbit a terrain plane with an attached Lensflare.

For the skydome and hemisphere light color values, I modulate them based on the directional light distance from the plane.


What about this example?


Great stuff, thanks a lot!
In my case I would need to model the simulation with current data of the user (location and time) to do a skymap that could be accurate and realistic to what he sees wherever she is ( the webgl shaders example suggested by @prisoner849 looks just what I need, despite I won’t have an horizon or “earth”, the idea is to see just the globe of the atmosphere and the sun around the planet)

I imagine it would be easy to use the GPS location and time values with simple JS as parameters?

also, is possible to use some kind of AR controls that could allow to move the viewport using the phone (as one of those AR skymaps?). Any link? I can’t find anything related in the examples section.

I tried to modify the example with the sun position calculations but the calculated coordinates of the Sun won’t update the model (and the values and the apparent movement of the sun are totally wrong, in my case near the Equator, I even did the calculation for 0-1 / 0-360 degrees azimuth and 0.5-0 / 0-90 degrees altitude, the idea is that azimuth is 360 degrees on the horizon and altitude describing a curve from 0 in the horizon to 90 degrees in the zenith). Somebody can throw some light into this issue? Thanks a lot.

The script is at