Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

76
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda