xxxxxxxxxx
function setup() {
createCanvas(800, 800, WEBGL);
//optional
debugMode(); // Add a grid and an axes guide. RGB indicate XYZ, respectively (so Red is X axis. Direction of the stick outward indicates +ve on that axis.)
//optional
//Set up a non-default camera position and facing. You *can* delete these and accept the defaults
let myCamera = createCamera();
myCamera.move(1500, -300, -1500);
myCamera.lookAt(0, 0, 0);
angleMode(DEGREES)
}
function draw() {
randomSeed(3456)
background(255, 200, 175);
//allow mouse to be used to "orbit" the camera around the origin
orbitControl(5, 5, 0.01);
//Add some lights (every frame!) ------------------------------------------------
//Add directional light to surfaces which face it
//Params: (color, directionVector)
directionalLight(color("#3f0000"), 1, 1, 1);
directionalLight(color("#003300"), -1, 1, -1);
directionalLight(color("#000053"), 1, -1, -1);
//Add a little light evenly to ALL surfaces. Not too much or we'll see no shadow
ambientLight(200);
//Draw some shapes! -------------------------------------------------------------
noStroke();
//Set material for the next shape(s) to be drawn
ambientMaterial(color(200));
//draw box at current origin, with dimensions width, height, depth
const spacing = 50;
for (let posX = -500; posX < 500; posX += spacing) {
for (let posY = -500; posY < 500; posY += spacing) {
for (let posZ = -500; posZ < 500; posZ += spacing) {
let isWithinRadius = false //dist(posX, posY, posZ, 0, 0, 0) < 500
let n = noise(9999+posX/1000, 9999+posY/1000, 9999+posZ/1000)
if (!isWithinRadius&&n<0.5) {
push();
translate(posX, posY, posZ)
box(spacing, spacing, spacing)
pop();
}
}
}
}
}