
var cameraPosition;
var eyePosition;
var target;
var gridScale = 400;
var et = 1 / 30;
var mode;

// globals
var canvas;               // the canvas
var devicePixelRatio = window.devicePixelRatio || 1;

function rand(min, max) {
  if (max === undefined) {
    max = min;
    min = 0;
  }
  return Math.random() * (max - min) + min;
}

function createGrid(size, subdivisions) {
  var numLines = subdivisions;
  var numVertices = numLines * 4;
  var positions = twgl.primitives.createAugmentedTypedArray(3, numVer