cam3d
cam3d is a small module for working with 3D in WebGL, DOM, or 2D Canvas. It will be the basis for higher-level APIs down the road, but also stands on its own if you need basic 3D effects or low-level control over your scenegraph (e.g. working with Canvas gradients, clipping, etc).
code snippet
var cam = fieldOfView viewportWidth viewportHeight; camposition; //change camera positioncam; //Look at (0, 0, 0) origincamup; //Adjust up-vectorcam; //update matrices ... for WebGL ... //upload the Float32Array gl; ... for Canvas ... //project the 3D position into a 2D screen-space position cam; //draw something at that location context;
docs
See the wiki for now.
live examples
Click the images to see the demos.
a rotating 3D window with snow outside -- source code
spinning 3D particles -- source code
roadmap
cam3d
and its related modules (like vecmath
) are still a work in progress; more documentation will be added soon.
The tools are intended to be decoupled from higher-level functionality, like WebGL features. If you are looking for a WebGL module, you can use these modules together with kami or another WebGL renderer. Some other modules that may be useful in the future:
- Efficient sprite tinting for Canvas 2D (currently in development)
- Higher-level 3D features, like depth-testing, texture-mapped triangles, lighting, etc.
- A unified API for loading sprites with WebGL and 2D Canvas
- Hit-detection and ray picking for 3D