xxxxxxxxxx
38
let angle = 0;
let sunRadius = 100
function setup() {
createCanvas(600, 600, WEBGL);
}
function draw() {
background(0);
push()
translate(-width / 2 + sunRadius, -height / 2 + sunRadius, 0)
// Sun position and rotation
rotateY(angle); // Rotating the sun
angle += 0.01;
// Set up lighting
ambientLight(50); // Soft ambient light
pointLight(255, 255, 100, 0, 0, 300); // Point light mimicking sunlight
// Create the sun (a 3D sphere)
push()
noStroke();
emissiveMaterial(255, 204, 0); // Glowing yellow/orange material
sphere(50); // Sun size
pop()
// Create a glowing halo effect around the sun
push()
noFill();
stroke(255, 204, 0, 100); // Semi-transparent yellow for glow
strokeWeight(4);
sphere(50); // Slightly larger sphere to act as a glow halo
pop()
pop()
}