Skip to content
Three.js module for animated sprites
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
AnimatedSprites.js
README.md

README.md

AnimatedSprites

Three.js module for animated sprites.

Tryed to make fast and useful animated sprites for Three.js library.

Requires

  • Three.js
  • underscore

Links

Sprite viewer - Performance testing

Code example

var spriteGroup = new THREE.AnimatedSprites.SpritesGroup(image, {
                        sprites:{
                            walk: {
                                offset:[0, 0],
                                size:[32*3, 32],
                                frameWidth: 32,
                                frameHeight: 32,
                                framesCount: 3,
                                speed: 200,           //full animation time ms.
                                rotationAroundX: 0,   //degrees
                                spriteRotation: 0     //degrees
                            },
                            run: {
                                offset:[0, 32],
                                size:[64*3, 64],
                                frameWidth: 64,
                                frameHeight: 64,
                                framesCount: 6,
                                speed: 400,           //full animation time ms.
                                rotationAroundX: 0,   //degrees
                                spriteRotation: 0     //degrees
                            }
                        }
                    }
            );
var sprite_mesh = spriteGroup.getNewSprite("walk",{position: new THREE.Vector3(40,40,40)});
scene.add(sprite_mesh);
//....
//...
sprite_mesh.changeSprite("run");

also do not forget to write

THREE.AnimatedSprites.update(delta);

in yours render function

Something went wrong with that request. Please try again.