From 73038c06e2d4e0ca0c961daa9e748e277863d08d Mon Sep 17 00:00:00 2001 From: Kevin Midboe Date: Wed, 11 Jul 2018 17:59:21 +0200 Subject: [PATCH] Added index and js file. --- index.html | 17 +++++++++++++++++ public/sketch.js | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 index.html create mode 100644 public/sketch.js diff --git a/index.html b/index.html new file mode 100644 index 0000000..c5aafcc --- /dev/null +++ b/index.html @@ -0,0 +1,17 @@ + + + + + + + Cubewaves + + + + + + + +

Hello world

+ + diff --git a/public/sketch.js b/public/sketch.js new file mode 100644 index 0000000..53263cb --- /dev/null +++ b/public/sketch.js @@ -0,0 +1,32 @@ +let angle = 0; +let w = 24; + +function setup() { + createCanvas(400, 400, WEBGL); +} + +function draw() { + background(175); + ortho(); + directionalLight(255, 255, 255, 0, -1, 0); + + translate(0, 50, -50); + rotateX(PI / 8); + + rectMode(CENTER); + + let offset = 0; + for (let x = 0; x < width; x += w) { + push(); + let a = angle + offset; + let h = map(sin(a), -1, 1, 0, 100); + translate(x - width / 2, 0, 0); + ambientMaterial(255); + box(w, h, w); + //rect(x - width / 2 + w / 2, 0, w - 2, h); + offset += 0.1; + pop(); + } + + angle += 0.1; +}