xxxxxxxxxx
//Sketch
var frame = 0;
var max_frames = 70;
let dimx = 1000;
let dimy = dimx;
var lon_samples = 50;
var lat_samples = 15;
var radius = dimx/4;
function preload() {
font = loadFont("OpenSans-Light.ttf");
}
function setup() {
var p5Canvas = createCanvas(dimx, dimy, WEBGL);
canvas = p5Canvas.canvas;
smooth(8);
var globe = [];
for (var i = 0; i < lat_samples; i++) {
globe[i] = [];
for (var j = 0; j < lon_samples; j++) {
globe[i][j] = 0;
}
}
}
function draw() {
background(22);
setText();
var globe = [];
var frame_percentage = frame / max_frames;
for (var i = 0; i < lat_samples; i++) {
b = [];
var latitude =
map(i, 0, lat_samples, 0, PI) +
map(frame_percentage, 0, 1, 0, PI / lat_samples);
for (var j = 0; j < lon_samples; j++) {
var longitude = map(j, 0, lon_samples, 0, TWO_PI);
var x = radius * sin(latitude) * cos(longitude);
var y = radius * sin(latitude) * sin(longitude);
var z = radius * cos(latitude);
b.push(createVector(x, y, z));
}
globe.push(b);
}
stroke(180);
strokeWeight(2);
rotateX((30 * PI) / 180);
rotateY((30 * PI) / 180);
for (var i = 0; i < lat_samples; i++) {
for (var j = 0; j < lon_samples - 1; j++) {
line(
globe[i][j].x,
globe[i][j].y,
globe[i][j].z,
globe[i][j + 1].x,
globe[i][j + 1].y,
globe[i][j + 1].z
);
}
line(
globe[i][lon_samples - 1].x,
globe[i][lon_samples - 1].y,
globe[i][lon_samples - 1].z,
globe[i][0].x,
globe[i][0].y,
globe[i][0].z
);
}
frame++;
if (frame == max_frames) {
frame = 0;
}
}
// Writing the text underneath the drawing
function setText() {
fill(220);
textAlign(CENTER, CENTER);
textStyle(NORMAL);
textFont(font);
textSize(15);
text("ENDIKA AGUIRRE", 0, height / 3);
textSize(12);
text("NO. 1", 0, height / 3 + 20);
}