Player

class Communicator.Animation.Player()

Properties

animation

The animation played by this player

loop

The number of times the animation will repeat. Set to…

nodeIdOffset

A base offset value which will be applied to all node…

onComplete

Callback function to be called when the animation is…

speed

Scale value to be applied to animation time.

LoopIndefinitely

If loop is set to LoopIndefinitely, the animation will…

Methods

evaluate()

getAnimationTime()

getCurrentTime()

getState()

pause()

play()

reload()

setChannelEnabled()

setTime()

stop()


Properties

Communicator.Animation.Player.animation

The animation played by this player

Communicator.Animation.Player.loop

The number of times the animation will repeat. Set to LoopIndefinitely to repeat indefinitely. Default is 0

Communicator.Animation.Player.nodeIdOffset

A base offset value which will be applied to all node identifiers in the animation attached to this player. This is useful to play an authored animation for a model that has been loaded into the scene after initial startup. In this situation the authored node identifiers in the animation may not match up with the runtime node identifiers in the current scene. The Model.getNodeIdOffset function can be used on the loaded model’s root node to retrieve the correct offset value.

Communicator.Animation.Player.onComplete

Callback function to be called when the animation is complete. Will not be triggered if the player is looping.

Communicator.Animation.Player.speed

Scale value to be applied to animation time.

Communicator.Animation.Player.LoopIndefinitely

If loop is set to LoopIndefinitely, the animation will play repeatedly.

Methods

evaluate

Communicator.Animation.Player.evaluate(time, out)

Calculate the values for each channel of the associated Animation at the given time.

Arguments
  • time (number()) – The time at which to evaluate the animation.

  • out (Communicator.Animation.BatchedValues()) – Storage for the evaluated values. If supplied, this object will be returned instead of a new BatchedValues object. This allows values gathered from multiple players to be combined into one batch.

Return type

Communicator.Animation.BatchedValues

getAnimationTime

Communicator.Animation.Player.getAnimationTime()

Gets the current time in seconds of the entire animation.

Return type

number

getCurrentTime

Communicator.Animation.Player.getCurrentTime()

Gets the current time in seconds that the animation has been playing.

Return type

number

getState

Communicator.Animation.Player.getState()

Gets the current animation state.

Return type

Communicator.Animation.PlayerState

pause

Communicator.Animation.Player.pause()

Pauses animation playback.

Return type

void

play

Communicator.Animation.Player.play()

Starts playing the animation.

Return type

void

reload

Communicator.Animation.Player.reload()

Updates internal state of animation player.

Return type

void

Call this method after any part of the underlying animation has been updated.

setChannelEnabled

Communicator.Animation.Player.setChannelEnabled(channel, enabled)

Sets the enabled state for a channel in this players animation. All channels are enabled by default when a player is created. A channel that has been disabled will not have its value interpolated by the system until it is re-enabled

Arguments
  • channel ({  }()) – a channel from the underlying animation

  • enabled (boolean()) – boolean value indicating whether the channel should be enabled.

Return type

void

setTime

Communicator.Animation.Player.setTime(time)

Sets the current animation time.

Arguments
  • time (number()) – time in milliseconds

Return type

void

stop

Communicator.Animation.Player.stop()

Stops animation playback and resets the current time to 0.

Return type

void