fix: make Globe light position accurate

Takes UTC current time with timezone difference, based on noon
I guess thanks again ChatGPT + StackOverflow?
This commit is contained in:
2023-02-15 19:11:37 +01:00
parent fd77c6d24f
commit d4f0a7431c
2 changed files with 3 additions and 3 deletions

View File

@@ -17,4 +17,4 @@ void main() {
vec3 color = mix(nightColor, dayColor, mixAmount);
gl_FragColor = vec4(color, 1.0);
}
}

View File

@@ -18,8 +18,8 @@ export class Globe {
// Calculate local time for sun position
const date = new Date()
const localHour = date.getHours() + date.getTimezoneOffset() / 60
this.options.sunAngle = (localHour - 12) / 12
const localHour = date.getUTCHours() + date.getTimezoneOffset() / 60
this.options.sunAngle = 2 * Math.PI * (localHour - 12) / 24
// Parameters
this.params = {