Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

75
Views
convert 24 hour time into rotational value

ok, so a bit of an odd question, I have implemented a real-time system using Date() and Date.getTime(), And I have a plugin installed on my project (mz3d), I know how to use it, however I have run into a problem with the sun,

I need to convert 24 hour time from getTime() into a rotational value for mz3d's sun. however, the sun's topmost position in the sky is at 0 degrees and beneath the floor is 180 degrees.

my code is:

//variables
var d = new Date();
var hr= d.getHours();
var mn= d.getMinutes();
//conversion
var sun;
//mz3d command
mz3d.command('sun pitch',sun,0);

how would I calculate it so 12 to is 0 degrees and 24 or 0 is 180 degrees?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Thanks to RobG i found the following code works

var d = new Date();
minSinceMidnight = d.getTime()- d.setHours(
    0, 0, 0, 0
);
minSinceMidnight = Math.round(
    minSinceMidnight / 60000
);
var math1 = minSinceMidnight/1440;
var math2 = math1*360
//console.log(d);
//console.log(minSinceMidnight);
//console.log(math2);
var sun = math2+180
//console.log(
//    "sun pos = ", sun
//);
mz3d.command('sun pitch',sun,0);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!