I’ve just improved the WebGL tutorials:
- As promised, they now use
requestAnimationFrame— or, more precisely, the
requestAnimFramecross-browser compatibility function provided by this Google utility module — to schedule their repaints. This means that they won’t hog CPU/GPU time when the pages are on hidden tabs, which should help avoid getting WebGL an underserved reputation for unnecessary resource-hoggery.
- I’ve switched from the excellent and general-purpose vector/matrix library Sylvester (plus Vladimir Vukićević’s glUtils.js extensions thereto) to Brandon Jones’s screamingly fast but WebGL-specific glMatrix library.
I’ve got a bunch more changes in the pipeline, and I’m trying to work out which ones would be best done before I spend more time on the next lesson, on picking…
[UPDATE] I’ve just done one other change from the pipeline — removing the animation code from lessons 1 and 2, which don’t use it. It became clear while I did the rewrite for the changes above that having it in those two lessons was unhelpful and confusing, so now I introduce requestAnimationFrame when it’s actually needed, in lesson 3.
[UPDATE] As per a comment by Shy below, pointing out that the normal matrix my lessons use is fundamentally broken, I’ve fixed that too. It’s odd, because I thought I’d made that change after a suggestion by Coolcat long ago — must have dropped the ball there. It’s done now, anyway.