image of earth
This commit is contained in:
parent
9c527bec23
commit
5ac636a99c
4 changed files with 32 additions and 3 deletions
30
sketch.js
30
sketch.js
|
@ -1,6 +1,13 @@
|
|||
let charges = new Map();
|
||||
let counter = 0;
|
||||
|
||||
let sphere_mode = 'circles';
|
||||
let sphere_radius = 200;
|
||||
|
||||
function preload() {
|
||||
earth = loadImage("atlas1.jpg");
|
||||
}
|
||||
|
||||
function setup() {
|
||||
createCanvas(600, 600, WEBGL);
|
||||
}
|
||||
|
@ -10,7 +17,7 @@ function draw() {
|
|||
background(50);
|
||||
|
||||
make_lights();
|
||||
draw_sphere(200, 25);
|
||||
draw_sphere(sphere_radius, 25);
|
||||
}
|
||||
|
||||
function draw_sphere(radius, n_axis_circles) {
|
||||
|
@ -21,7 +28,7 @@ function draw_sphere(radius, n_axis_circles) {
|
|||
rotateX(TAU / 4);
|
||||
draw_circles(
|
||||
radius,
|
||||
n_axis_circles,
|
||||
sphere_mode === 'earth' ? 2 : n_axis_circles,
|
||||
color(0x00, 0x9f, 0xff),
|
||||
color(0xff, 0x9f, 0x00),
|
||||
);
|
||||
|
@ -30,11 +37,22 @@ function draw_sphere(radius, n_axis_circles) {
|
|||
rotateY(TAU / 4);
|
||||
draw_circles(
|
||||
radius,
|
||||
n_axis_circles,
|
||||
sphere_mode === 'earth' ? 2 : n_axis_circles,
|
||||
color(0xff, 0x00, 0xff),
|
||||
color(0x00, 0xff, 0x00),
|
||||
);
|
||||
pop();
|
||||
|
||||
if (sphere_mode === 'earth') {
|
||||
noStroke();
|
||||
noFill();
|
||||
tint(0xff, 0x9f);
|
||||
texture(earth);
|
||||
push();
|
||||
rotateY(TAU / 4);
|
||||
sphere(radius);
|
||||
pop();
|
||||
}
|
||||
}
|
||||
|
||||
function draw_circles(radius, n_circles, pole_1_color, pole_2_color) {
|
||||
|
@ -64,3 +82,9 @@ function make_lights() {
|
|||
directionalLight(0x1f, 0x1f, 0x1f, light);
|
||||
ambientLight(0xbf);
|
||||
}
|
||||
|
||||
function keyPressed() {
|
||||
if (key == 'd') {
|
||||
sphere_mode = sphere_mode === 'earth' ? 'circles' : 'earth';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue