babylon-atlas-sprite
v0.2.1
Published
A texture-atlas sprite class for Babylon.js
Downloads
1
Maintainers
Readme
babylon-atlas-sprite
A Babylon.js object that shows frames from a texture atlas (img+JSON).
Usage:
var AtlasSprite = require('babylon-atlas-sprite')
var sprite = new AtlasSprite('sprites.png', 'sprites.json', scene, BABYLON)
// standard babylon objects exposed as 'mesh', 'material', 'texture'
sprite.mesh.position.x = 5
// set frame to names specified in the json
sprite.setFrame( 'frame003' )
Live demo here.
Installation
npm install babylon-atlas-sprite
To see example locally:
cd babylon-atlas-sprite
npm install
npm test
API
var AtlasSprite = require('babylon-atlas-sprite')
new AtlasSprite( imgURL, jsonURL, scene, BABYLON, noMipMap, samplingMode )
sprite.frames // array of frame names from JSON
sprite.setFrame(frameName)
sprite.setFrame(num) // same as: sprite.setFrame(sprite.frames[num])
sprite.dispose()