xxxxxxxxxx
44
let scl = 20;
let terrain = [];
var flying = 0;
function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
angleMode(DEGREES);
for (var x = 0; x < width/scl; x++) {
terrain[x] = [];
for (var y = 0; y < height/scl; y++) {
terrain[x][y] = 0;
}
}
}
function draw() {
orbitControl();
flying -= 0.1;
var yoff = flying;
for (var y = 0; y < height/scl; y++) {
var xoff = 0;
for (var x = 0; x < width/scl; x++) {
terrain[x][y] = map(noise(xoff, yoff), 0, 1, -100, 100);
xoff += 0.2;
}
yoff += 0.2;
}
background(0);
noFill();
stroke(255);
translate(-width/2, 200, -600)
rotateX(90);
for(let y = 0; y < height/scl; y++){
beginShape(TRIANGLE_STRIP);
for(let x = 0; x < width/scl; x++){
vertex(x * scl, y * scl, terrain[x][y]);
vertex(x * scl, (y + 1) * scl, terrain[x][y + 1]);
}
endShape();
}
}