What is C3DL?
The Canvas 3D JS Libary (C3DL) is a javascript library that will make it easier to write 3D applications using canvas 3d. It will provide a set of math, scene, and 3d object classes to make the canvas more accessible for developers that want to develop 3D content in browser but do not want to have to deal in depth with the 3D math needed to make it work.
If you are viewing this page with a canvas 3d enabled browser, you would see a textured spinning teapot inside the canvas area of this page. If not, you would see a screen shot.
The content above was created using the canvas 3d js library, release 0.3. The source code for the above is included below:
var cams = new FreeCamera();
var moverate=0.002;
function setupcanvas(canvasName){
var renderers=new OpenGLES11();
var scns = new Scene();
scns.setCanvasTag(canvasName);
scns.setRenderer(renderers);
scns.setCamera(cams);
rc= scns.init();
if(rc){
var lights = new LightManager(scns.getGL());
lights.setPosition(0,new Array(0,10,-20,1));
lights.setAmbient(0, new Array(3,3,3,3));
lights.setDiffuse(0, new Array(4,4,4,1));
lights.setSpecular(0,new Array(1,1,1,1));
lights.enable(0,true);
models=new Model();
models.setTexture(scns.getGL(),"ball.jpg");
models.init(teapot2Vertices,teapot2Normals,teapot2UVs,teapot2Faces);
scns.addObjectToScene(models);
cams.setPosition(new Array(0, 1, -2.25));
cams.setLookAtPoint(new Array(0, 0, 0.001));
scns.setUpdateCallback(movecam);
scns.startScene();
}
return rc;
}
function movecam(time){
var oldpos = cams.getPosition();
var newx = Math.cos(time*moverate)*oldpos[0]-Math.sin(time*moverate)*oldpos[2];
var newz = Math.cos(time*moverate)*oldpos[2]+Math.sin(time*moverate)*oldpos[0];
cams.setPosition(new Array(newx,oldpos[1],newz));
}

