/* eslint-disable no-undef*/
/**
* with a little help from
* Fabian Morón Zirfas
*/
var myHeight = 60;
var radius = 60;
var counter = 0;
var increment = 1;
var light_r = 250;
var light_g = 250;
var light_b = 250;
var light_a = 255;
function setup() {
createCanvas(500, 500, WEBGL);
}
function drawACone(_x, _y) {
push();
translate(_x, _y);
rotateX(radians(90));
cone(radius, myHeight);
pop();
}
function draw() {
camera(0, 0, 300);
background(250);
counter += increment;
if(counter === 120) {
increment = -1;
}else if(counter === 0) {
increment = 1;
}
// change the x,y position of the
// light by using a circle path
var light_x = sin(radians(counter)) * radius;
var light_y = cos(radians(counter)) * radius;
var light_z = counter * 4;
pointLight(light_r, light_g, light_b, light_a, light_x, light_y, light_z);
// this should actually be a rule to create
// the grid of cones ;-)
drawACone(0, 0);
drawACone(0, radius * 2);
drawACone(0, -radius * 2);
drawACone(-radius * 2, 0);
drawACone(radius * 2, 0);
drawACone(radius * 2, radius * 2);
drawACone(-radius * 2, -radius * 2);
drawACone(radius * 2, -radius * 2);
drawACone(-radius * 2, radius * 2);
drawACone(0, -radius * 4);
drawACone(0, radius * 4);
drawACone(radius * 4, 0);
drawACone(-radius * 4, 0);
}