debugged and simplified JS to WebGL code