image of earth
This commit is contained in:
parent
9c527bec23
commit
5ac636a99c
4 changed files with 32 additions and 3 deletions
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
atlas1.jpg filter=lfs diff=lfs merge=lfs -text
|
1
assets.json
Normal file
1
assets.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"atlas1.jpg":"https://www.paul-reed.co.uk/images/atlas1.jpg"}
|
BIN
atlas1.jpg
(Stored with Git LFS)
Normal file
BIN
atlas1.jpg
(Stored with Git LFS)
Normal file
Binary file not shown.
30
sketch.js
30
sketch.js
|
@ -1,6 +1,13 @@
|
||||||
let charges = new Map();
|
let charges = new Map();
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
|
|
||||||
|
let sphere_mode = 'circles';
|
||||||
|
let sphere_radius = 200;
|
||||||
|
|
||||||
|
function preload() {
|
||||||
|
earth = loadImage("atlas1.jpg");
|
||||||
|
}
|
||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
createCanvas(600, 600, WEBGL);
|
createCanvas(600, 600, WEBGL);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +17,7 @@ function draw() {
|
||||||
background(50);
|
background(50);
|
||||||
|
|
||||||
make_lights();
|
make_lights();
|
||||||
draw_sphere(200, 25);
|
draw_sphere(sphere_radius, 25);
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw_sphere(radius, n_axis_circles) {
|
function draw_sphere(radius, n_axis_circles) {
|
||||||
|
@ -21,7 +28,7 @@ function draw_sphere(radius, n_axis_circles) {
|
||||||
rotateX(TAU / 4);
|
rotateX(TAU / 4);
|
||||||
draw_circles(
|
draw_circles(
|
||||||
radius,
|
radius,
|
||||||
n_axis_circles,
|
sphere_mode === 'earth' ? 2 : n_axis_circles,
|
||||||
color(0x00, 0x9f, 0xff),
|
color(0x00, 0x9f, 0xff),
|
||||||
color(0xff, 0x9f, 0x00),
|
color(0xff, 0x9f, 0x00),
|
||||||
);
|
);
|
||||||
|
@ -30,11 +37,22 @@ function draw_sphere(radius, n_axis_circles) {
|
||||||
rotateY(TAU / 4);
|
rotateY(TAU / 4);
|
||||||
draw_circles(
|
draw_circles(
|
||||||
radius,
|
radius,
|
||||||
n_axis_circles,
|
sphere_mode === 'earth' ? 2 : n_axis_circles,
|
||||||
color(0xff, 0x00, 0xff),
|
color(0xff, 0x00, 0xff),
|
||||||
color(0x00, 0xff, 0x00),
|
color(0x00, 0xff, 0x00),
|
||||||
);
|
);
|
||||||
pop();
|
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) {
|
function draw_circles(radius, n_circles, pole_1_color, pole_2_color) {
|
||||||
|
@ -64,3 +82,9 @@ function make_lights() {
|
||||||
directionalLight(0x1f, 0x1f, 0x1f, light);
|
directionalLight(0x1f, 0x1f, 0x1f, light);
|
||||||
ambientLight(0xbf);
|
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