diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..48e5c18 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +atlas1.jpg filter=lfs diff=lfs merge=lfs -text diff --git a/assets.json b/assets.json new file mode 100644 index 0000000..1b8a842 --- /dev/null +++ b/assets.json @@ -0,0 +1 @@ +{"atlas1.jpg":"https://www.paul-reed.co.uk/images/atlas1.jpg"} diff --git a/atlas1.jpg b/atlas1.jpg new file mode 100644 index 0000000..6a0c1fa --- /dev/null +++ b/atlas1.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:59a410f2fdf3fc7466ffcfbeeff6fd9c641dc662af16f5a6d1003b42b96a999a +size 362026 diff --git a/sketch.js b/sketch.js index 37f3859..a88cb82 100644 --- a/sketch.js +++ b/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'; + } +}