Add completed RGB cube

This commit is contained in:
Lev
2021-07-28 00:05:35 -05:00
parent cf65b0aa96
commit 33ca84b194
3 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="p5.min.js"></script>
<script src="sketch.js"></script>
</body>
</html>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,37 @@
let sun;
let earth;
let moon;
let myStars;
let starsBack;
function setup() {
createCanvas(800, 800, WEBGL);
angleMode(DEGREES);
}
function draw() {
background(150);
ambientLight(255);
ambientMaterial(100, 150, 200);
let max = 10;
noStroke();
rotateY(frameCount);
rotateZ(frameCount);
translate(-30*max/2, -30*max/2, -30*max/2);
for(let x=0; x<max; x++)
{
for(let y=0; y<max; y++)
{
for(let z=0; z<max; z++)
{
push();
ambientMaterial(map(x, 0, max, 0, 255), map(y, 0, max, 0, 255), map(z, 0, max, 0, 255));
translate(x * 30, y * 30, z * 30);
box(30, 30, 30);
pop();
}
}
}
}