javascript 3d rendering

What I did

Once upon a workday, I decided it would be fun to learn JavaScript. Web development has been one of my hobbies1 for a while now, and JavaScript appears to be an increasingly fundamental piece of the internet pie.

As a student at DigiPen Institute of Technology, my greatest interest was in graphics programming. So much so that one of our projects in which we made a primitive 3D rendering pipeline entirely in software was so intriguing to me that I chose to take it well beyond the course requirements.

‘Well,’ I thought, ‘to get my 3D renderer to run in JavaScript I’d really need to get a good grasp of the language.’ It seemed like a sufficient task to keep me motivated. So with that idea, my porting was underway. Here is the result (if your browser supports the canvas tag):

Your browser does not support HTML5 Canvas.

What I learned

  1. Javascript is an honest-to-God programming language. Sure it’s made for “scripting”, but it’s very functional and well conceived.
  2. Webkit browsers come standard with a decent set of development tools built right in, including a great debugger and profiler. It’s actually quite an advanced environment. Clearly, there are web developers who use these tools every day. Otherwise, I can’t imagine how such a thorough toolset magically appeared.
  3. Firefox appears to be way behind Safari/Chrome in JavaScript performance. Granted it may just be tuned to normal case scripting tasks. I doubt JavaScript was initially conceived with a 3D software rasterizer in mind.
  4. Most importantly, I learned how much there is to learn. I still know nothing of this so called jQuery business. Maybe one of these days I’ll actually get a good idea, and make a iOS web app.

Is this useful?

Probably not. This renderer is far from optimized. I’m sure the JavaScript code is creating way too many objects. Also, it’s lacking many optimizations standard to a rendering system. No z-buffer, no clipping, and it’s doing full per-pixel hyperbolic interpolation too, which you don’t understand, but it was fun to say.

I hope you’ve found this interesting. I normally write about Apple and other tech stuff here. If that interests you, feel free to subscribe, or follow @skoda on twitter. Or not, I don’t care.


  1. Hobbies, as I refer to them, are only differentiated from work in that no one gives me money for them (yet)

June 30, 2010 at 4:09 pm

@skoda on App.net @technochocolate on App.net