WIP refactoring the webglapp.js spaghetti ball.