WebGL implementation, rewrite for CoffeeScript