WebGL utilities for performant and flexible 2D and 3D rendering.
Kami is now breaking into small and composable modules that will be published separately to NPM. Most new work is under the stackgl ecosystem. However, some higher-level 2D game abstractions may be eventually built on top of these modules under the kami namespace.
Kami is a fast and lightweight WebGL sprite rendering framework.
It is ideal for tinkering with WebGL, building your game engine on top of, or writing applications that require low-level control over vertex data, textures, and so forth.
This library is still in development.
Here is an example using Node style requires and browserify:
//require the necessary classes from the 'kami' modulevar AssetManager = require'kami'AssetManager;var SpriteBatch = require'kami'SpriteBatch;var WebGLContext = require'kami'WebGLContext;var width = 256;var height = 256;//create our webGL context..//this will manage viewport and context loss/restorevar context = width height;//add the GL canvas to the DOMdocumentbodyappendChildcontextview;//Create a new batcher for 2D spritesvar batch = context;//Create a new texture. This will load the URL asynchronouslyvar tex0 = context "img/mysprite.png";//kami aliases some Texture GLenums for conveniencetex0setFilterTextureFilterLINEAR;//Start our render looprequestAnimationFramerender;requestAnimationFramerender;var gl = contextgl;//clear the GL canvasglclearglCOLOR_BUFFER_BIT;//start the batch...batchbegin;//draw the texture at (75, 75) with a size of 100x100batchdrawtex0 75 75 100 100;//draw it some other placesbatchdrawtex0 0 0 15 25;batchdrawtex0 100 100;//flush sprites to GPUbatchend;
The demos are hosted in another package, see here: https://github.com/mattdesl/kami-demos
If you aren't using Node and
require() statements, you can grab the UMD build at
Most of the code looks exactly the same, except all of Kami's objects are exported onto a global
kami namespace. The dependencies are also exported on the namespace, for convenience. See here:
- WebGL2 utils: compressed textures (done, see kami-demos), texture arrays, float textures, instanced draws, etc.
- Cube maps and other Texture utils
- clean up asset loading and kami-assets
- MRTs for FrameBuffer utility (WebGL2)
- SpriteBatch should use matrices (projeciton/transform)
- SpriteBatch needs rotation