I took all the maths from OpenGL, but I haven’t copied the function calls so it isn’t a GL implementation. There is no texture mapping at the moment, but it wouldn’t be at all difficult to add – although the speed issues mean that it will probably grind a bit. It does have per-pixel fragment shading, and the shaders I’ve used in the links below use Phong shading.
The code could probably still go a bit faster. I’m using a barycentric coordinates to interpolate values in the frame buffer. A scanline alternative may give an improvement, although tests did not show a speed up. I think the major blockage is that the renderer is quite complex, it even has its own shader implementation, which makes the render loop expensive. One nice thing about doing this in software is that I can make the background transparent and render on top of whatever background is in the webpage – which could be used to make some nice effects in a browser.
Ultimately JS implementations are not quite fast enough yet, but Chrome in particular is getting there – so maybe in a couple of years this might be a bit more practical.
Utah Teapot (3644 vertices, 6320 triangles)
Happy Buddha (3701 vertices, 7390 triangles)
Stanford Bunny (35947 vertices, 69451 triangles)