threejs_daynight icon indicating copy to clipboard operation
threejs_daynight copied to clipboard

Convert `var time = new Date().getTime() * 0.0002` into client time

Open 5ervant opened this issue 5 years ago • 2 comments

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()}`;

5ervant avatar Apr 03 '19 16:04 5ervant

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).

dirkk0 avatar Apr 04 '19 16:04 dirkk0

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.

5ervant avatar Apr 16 '19 15:04 5ervant