threejs_daynight
threejs_daynight copied to clipboard
Convert `var time = new Date().getTime() * 0.0002` into client time
How do you convert var time = new Date().getTime() * 0.0002
into client time?
I've tried the following but have no luck:
const d = new Date();
const time = `${d.getHours()}.${d.getMinutes()}`;
I assume you want to change the code so that the sun is in sync with your local time?
One way to do this would be to calculate the percentage of daytime and sync that with the sun: https://codepen.io/dirkk0/pen/OGNyJP But of course this depends on where you are - the codepen would be on the equator (i.e. no shadows on high noon).
I assume you want to change the code so that the sun is in sync with your local time?
Yes, you're right!
Thanks for the help but upon observing since implementing that, like for example, right now it's already 11 PM here but the scene is pretty bright, it looks not matching a client time, you can view your codepen sample. And also almost all shadows are now gone every time I check my work.