API Reference

Class List

AnimComponentLayer

The Anim Component Layer allows managers a single layer of the animation state graph.

Summary

Properties

activeState

Returns the currently active state name.

activeStateCurrentTime

The active states time in seconds.

activeStateDuration

Returns the currently active states duration.

activeStateProgress

Returns the currently active states progress as a value normalized by the states animation duration.

mask

A mask of bones which should be animated or ignored by this layer.

name

Returns the name of the layer.

playable

Returns true if a state graph has been loaded and all states in the graph have been assigned animation tracks.

playing

Whether this layer is currently playing.

previousState

Returns the previously active state name.

states

Lists all available states in this layers state graph.

transitioning

Returns whether the anim component layer is currently transitioning between states.

transitionProgress

If the anim component layer is currently transitioning between states, returns the progress.

weight

The blending weight of this layer.

Methods

assignAnimation

Assigns an animation track to a state or blend tree node in the current graph.

blendToWeight

Blend from the current weight value to the provided weight value over a given amount of time.

getAnimationAsset

Returns the asset that is associated with the given state.

pause

Pause the animation in the current state.

play

Start playing the animation in the current state.

rebind

Rebind any animations in the layer to the currently present components and model of the anim components entity.

removeNodeAnimations

Removes animations from a node in the loaded state graph.

reset

Reset the animation component to its initial state, including all parameters.

transition

Transition to any state in the current layers graph.

Details

Constructor

AnimComponentLayer(name, controller, component, [weight], [blendType], [normalizedWeight])

Create a new AnimComponentLayer instance.

Parameters

namestring

The name of the layer.

controllerobject

The controller to manage this layers animations.

componentAnimComponent

The component that this layer is a member of.

weightnumber

The weight of this layer. Defaults to 1.

blendTypestring

The blend type of this layer. Defaults to ANIM_LAYER_OVERWRITE.

normalizedWeightboolean

Whether the weight of this layer should be normalized using the total weight of all layers.

Properties

stringactiveState

Returns the currently active state name.

numberactiveStateCurrentTime

The active states time in seconds.

numberactiveStateDuration

Returns the currently active states duration.

numberactiveStateProgress

Returns the currently active states progress as a value normalized by the states animation duration. Looped animations will return values greater than 1.

objectmask

A mask of bones which should be animated or ignored by this layer.

entity.anim.baseLayer.mask = {
    // include the spine of the current model and all of its children
    "path/to/spine": {
        children: true
    },
    // include the hip of the current model but not all of its children
    "path/to/hip": true
};
stringname

Returns the name of the layer.

stringplayable

Returns true if a state graph has been loaded and all states in the graph have been assigned animation tracks.

stringplaying

Whether this layer is currently playing.

stringpreviousState

Returns the previously active state name.

string[]states

Lists all available states in this layers state graph.

booleantransitioning

Returns whether the anim component layer is currently transitioning between states.

number, nulltransitionProgress

If the anim component layer is currently transitioning between states, returns the progress. Otherwise returns null.

numberweight

The blending weight of this layer. Used when calculating the value of properties that are animated by more than one layer.

Methods

assignAnimation(nodePath, animTrack, [speed], [loop])

Assigns an animation track to a state or blend tree node in the current graph. If a state for the given nodePath doesn't exist, it will be created. If all states nodes are linked and the AnimComponent#activate value was set to true then the component will begin playing.

Parameters

nodePathstring

Either the state name or the path to a blend tree node that this animation should be associated with. Each section of a blend tree path is split using a period (.) therefore state names should not include this character (e.g "MyStateName" or "MyStateName.BlendTreeNode").

animTrackobject

The animation track that will be assigned to this state and played whenever this state is active.

speednumber

Update the speed of the state you are assigning an animation to. Defaults to 1.

loopboolean

Update the loop property of the state you are assigning an animation to. Defaults to true.

blendToWeight(weight, time)

Blend from the current weight value to the provided weight value over a given amount of time.

Parameters

weightnumber

The new weight value to blend to.

timenumber

The duration of the blend in seconds.

getAnimationAsset(stateName)

Returns the asset that is associated with the given state.

Parameters

stateNamestring

The name of the state to get the asset for.

Returns

Asset

The asset associated with the given state.

pause()

Pause the animation in the current state.

play([name])

Start playing the animation in the current state.

Parameters

namestring

If provided, will begin playing from the start of the state with this name.

rebind()

Rebind any animations in the layer to the currently present components and model of the anim components entity.

removeNodeAnimations(nodeName)

Removes animations from a node in the loaded state graph.

Parameters

nodeNamestring

The name of the node that should have its animation tracks removed.

reset()

Reset the animation component to its initial state, including all parameters. The system will be paused.

transition(to, [time], [transitionOffset])

Transition to any state in the current layers graph. Transitions can be instant or take an optional blend time.

Parameters

tostring

The state that this transition will transition to.

timenumber

The duration of the transition in seconds. Defaults to 0.

transitionOffsetnumber

If provided, the destination state will begin playing its animation at this time. Given in normalized time, based on the states duration & must be between 0 and 1. Defaults to null.