Constructor
new PlainSingularAnimator(texture, tilesAmountHorizontally, tilesAmountVertically, tilesTotalAmount, framesPerSecond)
Create a PlainSingularAnimator
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 PlainSingularAnimator(spriteTexture, 4, 4, 10, 15);
const texture = animator.init();
animator.animate();
Extends
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
- Overrides:
- Source:
Methods
animate()
Updates current frame in Texture, should be invoked in loop to allow updating the texture
Function stops at the end of the animation
- Overrides:
- Source:
Example
function animate() {
animator.animate();
requestAnimationFrame(animate);
}
Use if you want to play your animation with own loop function
init(startFrame) → {Texture}
Initializes Animator,
Parameters:
Name | Type | Default | Description |
---|---|---|---|
startFrame |
number | 0 | optional parameter for setting the start position of animation (frame number) |
- Overrides:
- Source:
Returns:
a Texture object that will display animation
- Type
- Texture
play()
Updates current frame in Texture
Function updates texture as long as animation lasts, then stops
Use if you want to play your animation only once
- Source: