Add completed RGB cube
This commit is contained in:
@ -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>
|
||||
3
CM2030 Graphics Programming/Week 13/13.1.4 RGB Cube/p5.min.js
vendored
Normal file
3
CM2030 Graphics Programming/Week 13/13.1.4 RGB Cube/p5.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user