I am making a simulation of the earth in p5.js, but I want to mirror the rotation of the real world earth in my simulation, in degrees.
when I researched I came empty up handed, so is there a server I can access, or a JavaScript object I can use to access this?
here is the code, if it would even help at all:
let earthTexture;
let cloudsTexture;
let angle = 0;
function preload()
{
earthTexture = loadImage("IMAGES/earth.jpg");
cloudsTexture = loadImage("IMAGES/clouds.png");
}
function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
}
function draw() {
background(10);
angle += (360 / (86400 * frameRate()));
orbitControl();
pointLight(255, 255, 200, -(12667 * width / 5), 0, 0);
ambientMaterial(0);
noStroke();
//creates a sphere for Earth
rotateY(angle);
texture(earthTexture);
sphere(width / 5);
//creates a sphere for the clouds
rotateY(angle * 1.1);
texture(cloudsTexture);
sphere(width / 4.8)
}
here is the project link as well:
https://editor.p5js.org/lolior234/full/QKLqBzAGS
I tried to use JavaScript’s date object, but when I used the toLocaleString() function, it returned a string, as well as other information and formatting I don’t need.