xxxxxxxxxx
58
let ugao = 0;
let podaci;
let r = 200;
let zemlja;
function preload() {
zemlja = loadImage('earth.jpg');
podaci = loadTable('https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_month.csv',
'header'
);
}
function setup() {
createCanvas(600, 600, WEBGL);
}
function draw() {
background(151);
rotateY(ugao);
ugao += 0.01;
lights();
fill(200);
noStroke();
texture(zemlja);
// normalMaterial();
sphere(r);
for (let red of podaci.rows) {
let lat = red.getNum('latitude');
let lon = red.getNum('longitude');
let mag = red.getNum('mag');
let teta = radians(lat);
let fi = radians(lon) + PI;
let x = r * cos(teta) * cos(fi);
let y = -r * sin(teta);
let z = -r * cos(teta) * sin(fi);
let vektor_pozicije = createVector(x, y, z);
let h = pow(10, mag);
let max_h = pow(10, 7);
let visina = map(h, 0, max_h, 10, 1000);
let osa_x = createVector(1, 0, 0);
let zuta = map(h, 0, max_h, 255, 0);
let ugaob = abs(osa_x.angleBetween(vektor_pozicije));
let osa_rotacije = osa_x.cross(vektor_pozicije);
push();
translate(x, y, z);
rotate(ugaob, osa_rotacije);
fill(255, zuta, 0);
box(visina, 2, 2);
pop();
}
}