npm

kami-batch2

2.0.4 • Public • Published

kami-batch

unstable

A fast and efficient 2D sprite batcher based loosely on LibGDX's implementation.

Usage

NPM

See examples folder for details. A full program could look like this:

//setup a canvas
var gl = require('webgl-context')({
    width: 512,
    height: 512
});
 
//an opaque white texture, useful for tinting lines and rectangles
var tex = require('kami-white-texture')(gl);
 
//create a sprite batcher
var batch = require('kami-batch')(gl);
 
batch.begin();
 
//tint the vertex attributes
batch.setColor(1,0,0);
 
//draw some sprites
batch.draw(tex, 0, 0, 256, 256);
batch.draw(tex, 5, 5, 12, 51);
 
//submit to GPU
batch.end();
 
//add to DOM
document.body.appendChild( gl.canvas );

Planned Changes

  • use projection matrices instead of a vector
  • support rotation on the fly

License

MIT, see LICENSE.md for details.

Package Sidebar

Install

npm i kami-batch2

Weekly Downloads

0

Version

2.0.4

License

MIT

Unpacked Size

17.7 kB

Total Files

5

Last publish

Collaborators

  • implicit-invocation