Code viewer for World: World View (Example)

See raw JS.

let fullwidth  = ABWorld.fullwidth();
let fullheight = ABWorld.fullheight();

let sun_img;
let theta = 0;

let font,
    font_size = 16;
    
function setup() {
    createCanvas(fullwidth, fullheight, WEBGL);
    
    sun_img = loadImage('uploads/alexmurphy1996/sun_surface.jpg');
    mercury = loadImage('uploads/alexmurphy1996/mercury.jpg');
    venus = loadImage('uploads/alexmurphy1996/venus.jpg');
    earth = loadImage('uploads/alexmurphy1996/world.jpg');
    mars = loadImage('uploads/alexmurphy1996/mars.jpg');
    jupiter = loadImage('uploads/alexmurphy1996/jupiter.jpg');
    saturn = loadImage('uploads/alexmurphy1996/saturn2.jpg');
    neptune = loadImage('uploads/alexmurphy1996/neptune.jpg');
}

function draw() {
    background('black');
    sun();
    system();
    theta += 5;
}

function system() {
    // Start making planets
    planet(20, 250, mercury);
    planet(40, 100, venus);
    planet(70, 150, earth);
    planet(40, 140, mars);
    planet(120, 200, jupiter);
    planet(90, 240, saturn);
    planet(40, 220, neptune);
}

function planet(size, pos, surface) {
    translate(pos, 0);
    push();
    rotateY(theta * 0.001);
    //pass image as texture
    texture(surface);
    sphere(size);
    pop();
}

function sun() {
    translate(-fullwidth/2, 0);
    push();
    rotateY(theta * 0.001);
    rotateX(theta * 0.001);
    rotateZ(theta * 0.001);
    //pass image as texture
    texture(sun_img);
    sphere(180);
    pop();
}