forked from JustNikhill/Solar-system
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsketch.js
More file actions
38 lines (29 loc) · 964 Bytes
/
sketch.js
File metadata and controls
38 lines (29 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Developer - JustNikhill
// LinkedIn - https://www.linkedin.com/in/nikhil-yadav-609435203/
// HackerRank - https://www.hackerrank.com/JustNikhil?hr_r=1
let sun;
let cam;
let sunTexture;
const textures = [];
// load the images in p5.js' preload() instead of in setup().
function preload() {
sunTexture = loadImage('data/sun.jpg');
textures[0] = loadImage('data/mars.jpg');
textures[1] = loadImage('data/earth.jpg');
textures[2] = loadImage('data/mercury.jpg');
}
function setup() {
let canvas = createCanvas(600, 600, WEBGL);
// Disable the context menu on the canvas so the camera can use the right mouse button
canvas.elt.oncontextmenu = () => false;
cam = createEasyCam({ distance: 500 });
sun = new Planet(50, 0, 0, sunTexture);
sun.spawnMoons(4, 1);
}
function draw() {
background(0);
ambientLight(255, 255, 255);
pointLight(255, 255, 255, 0, 0, 0);
sun.show();
sun.orbit();
}