Class: PlainAnimator

PlainAnimator(texture, tilesAmountHorizontally, tilesAmountVertically, tilesTotalAmount, framesPerSecond)

Basic Animator Class allows to animate texture in loop

Constructor

new PlainAnimator(texture, tilesAmountHorizontally, tilesAmountVertically, tilesTotalAmount, framesPerSecond)

Create a PlainAnimator
Parameters:
Name Type Description
texture Texture THREE Texture object with sprite image loaded
tilesAmountHorizontally number number of columns in your sprite image
tilesAmountVertically number number of rows in your sprite image
tilesTotalAmount number number of frames in your sprite image
framesPerSecond number number of frames per second, for example 15
Source:
See:
Example
const spriteTexture = new THREE.TextureLoader().load('sprite-texture.png')
const animator = new PlainAnimator(spriteTexture, 4, 4, 10, 15);
const texture = animator.init();
animator.animate();

Members

end

Getter for Observable that emits event on end of the animation note that when used in infinity loop, the event will be emitted every time animation completes
Source:

Methods

animate()

Updates current frame in Texture, should be invoked in loop to allow updating the texture
Source:
Example
function animate() {
   animator.animate();
   requestAnimationFrame(animate);
 }

init(startFrame) → {Texture}

Initializes Animator,
Parameters:
Name Type Default Description
startFrame number 0 optional parameter for setting the start position of animation (frame number)
Source:
Returns:
a Texture object that will display animation
Type
Texture