HTML5 Canvas MD2 Renderer

Hot on the heels of my PHP MD2 renderer that loads a Quake II MD2 model file and renders and rotates the model in 3D, I decided that it was clunky and to take advantage of new techniques in browsers

This is an HTML5 based Quake II MD2 model loader and renderer that I wrote to demonstrate file reading and canvases.

Your browser doesn’t support canvas.


I used the BinaryReader which was refactored by Vjeux although I had to slightly refactor it myself as I had problems getting floats to read properly. I quickly wrote my own function for calculating the IEE 754 Single precision floats rather than modify the function as doing it from scratch was quicker in the end, either way, it gave me the result I was after.

I also made use of the MD2 file format specification document by David Henry because I’m nowhere near smart enough to remember the headers every time I do an MD2 reader 🙂

This demo will not work in Internet Explorer 8 or less. Use Chrome, Firefox, Safari or Opera. They are all far better choices.


  1. looks damn good, any idea how to apply .pcx files on top of that wire frame to get colored skin models?

    I got some very old code in C for quake2 md2 modelling in opengl

    but would like to load quake2 models and rander them 3d to 2d in php

    can this be done easily, have you coded this?

    i.e. load a 3d model and display it at any angle as 2d .jpg image

  2. and best of all only used 5-7% cpu on my old 1.4ghz laptop

    very impressive for such a large image actually…

    just need a simple API so I can load .md2 files and apply .pcx image data on top of the .md2 wireframes

    such that I can render .pcx image data in php (render skins and models at any angle in php)

  3. Hey michael we have same idea & I’m developing my script long time ago. Still have some faulty. I can help you with some if you want too.

Leave a Reply

Your email address will not be published. Required fields are marked *