In order to write one you will need to first decide if you will support Excanvas, so IE can use it, or not.
That will set some limits on what you can do if you support IE.
Your best bet is to just start with creating some primary shapes, and most likely you will want to have certain primitives that everything else can be built from, so, you may want to look at OpenGL or DirectX, at their primitives.
Once you have that, and you can move them around in 3D space, then you will want to start looking at adding cameras, but that will be relatively easy compared to step 1.
Unfortunately, all of this is very heavy in math, so you will take a huge performance hit if you create several 3D objects that have to move frequently.
I think the best bet is to wait, as, in late 2007 there was blogs for Firefox and Opera to have 3D support in canvas: http://starkravingfinkle.org/blog/2007/11/animating-with-canvas/
The reason is that if it will be built into the browser then most of the heavy work will be done, esp if it supports some flavor of OpenGL.