let colorScale = chroma.scale(['#00429d', '#4771b2', '#73a2c6',
'#a5d5d8', '#ffffe0', '#ffbcaf',
'#f4777f', '#cf3759', '#93003a']).domain([-100, 100]);
let colorScale1 = chroma.scale(['#A6DA87', '#72DC61', '#35C059',
'#34DF69', '#ffffe0', '#955F54',
'#985D60', '#966671', '#93003a']).domain([-100, 100]);
let colorScale2 = chroma.scale(['#4F7098', '#74C3D8', '#7C99CB', '#76A3E7', '#FFFFFF']).domain([-50, 50]);
let colorScale3 = chroma.scale(['#FFCA41', '#F4FD74', '#F7FDC8']).domain([-50, 50]);
let colorScale4 = chroma.scale(['#6A76A7D1', '#74F0FD77', '#5B6BB1D1']).domain([-50, 50]);
createCanvas(windowWidth, windowHeight, WEBGL);
setAttributes('antialias', true);
easycam = createEasyCam({distance: 900, center: [0,0,0],rotation: [0.4,-0.75,0,0]});
for (let x = 0; x < cols; x++) {
radius = Math.min(rows, cols) / 2;
pointLight(255,255,255,100,100,100);
translate(-w / 2, -h / 2);
function createHatchPatternA(color) {
let pattern = createGraphics(20, 20);
pattern.line(0, 0, 20, 20);
pattern.line(20, 0, 0, 20);
pattern.circle(10,10,10);
pattern.line(10,10,20,20);
pattern.line(20,10,20,20);
function generateTerrain() {
for (let y = 0; y < rows; y++) {
for (let x = 0; x < cols; x++) {
terrain[x][y] = map(fBm(xoff, yoff), 0, 1, -100, 100);
for (let i = 0; i < octaves; i++) {
sum += amplitude * noise(x * frequency, y * frequency);
amplitude *= persistence;
function createParticles() {
for (let y = 0; y < rows; y++) {
for (let x = 0; x < cols; x++) {
x: x * scl * random(0.97, 1.03),
hatchPattern: createHatchPatternA(colorScale1(terrain[x][y]).hex())
particles.push(particle);
function updateParticles() {
for (let i = 0; i < particles.length; i++) {
let x = particles[i].x / scl;
let y = particles[i].y / scl;
let lowerBound = (currentRow - updateRange + rows) % rows;
let upperBound = (currentRow + updateRange) % rows;
if (lowerBound <= upperBound) {
if (y >= lowerBound && y <= upperBound) {
particles[i].z = lerp(particles[i].z, particles[i].targetZ, 0.1);
if (y >= lowerBound || y <= upperBound) {
particles[i].z = lerp(particles[i].z, particles[i].targetZ, 0.1);
currentRow = (currentRow + displaySpeed) % rows;
function drawParticles() {
for (let i = 0; i < particles.length; i++) {
texture(particles[i].hatchPattern);
translate(particles[i].x, particles[i].y, particles[i].z);
function drawParticlesB() {
for (let i = 0; i < particles.length; i++) {
texture(particles[i].hatchPattern);
stroke(colorScale3(particles[i].targetZ).lab());
translate(particles[i].x * 0.3, particles[i].y * 0.3, particles[i].z * 3);
function drawParticlesC() {
for (let y = 0; y < rows; y++) {
for (let x = 0; x < cols; x++) {
let distance = Math.sqrt((dx * dx) * (dy * dy));
fill(colorScale4(particles[particleIndex].targetZ).hex());
translate(particles[particleIndex].x, particles[particleIndex].y, particles[particleIndex].z * 1.2);
stroke(colorScale3(particles[particleIndex].targetZ).lab());
cylinder(partSizeC,partSizeC*random(2,10), 7, 2);