Sun Motion (with SkyMaterial)

Going to get straight to the point.
I need help creating an animation of the sun traveling as it does during the day, preferably using SkyMaterial’s sun inclination & azimuth (if that’s how it works). If that’s not possible, simply animating a Vector3 would suffice. I’m not aware of how the actual mechanics work and the wikipedia page was a bit much, so if anybody can give me code for this, that’d be great.

My current configuration is as such:

    const skybox = MeshBuilder.CreateBox("skyBox", { size: 300.0, updatable: false }, scene);
    skybox.disableEdgesRendering()
    const skyboxMaterial = new SkyMaterial("sky", scene);
    skyboxMaterial.disableDepthWrite = true;
    skyboxMaterial.backFaceCulling = false;
    skyboxMaterial.luminance = 0.9
    skyboxMaterial.rayleigh = 3
    skyboxMaterial.turbidity = 3
    skybox.material = skyboxMaterial;

how about this?
https://playground.babylonjs.com/#561ASU

3 Likes

As per the small PG above from @11128 you should be good using the skybox material. It’s something I used in my ‘snowball demo’. Obviously, inclination will make for the time of day. As for the fx of sunset, sunrise, dawn, dusk and night, I added the animation for turbidity and luminance. The azimuth however, as it’s name suggest should be set once for the scene. Unless of course, your scene moves to another region (latitude) or unless you want to implement a time of year mechanism. In any case, I guess you should be fine keeping with this base. May be you want to implement some steps for the changes in daytime (at least for dev). It can help you set better values for dawn, sunrise, mid-day, sunset, dusk, night. Once you’re happy with the different states, make your final night/day anim.

1 Like