copy code from webgl branch of the compiler

Not sure how to bring history along :/