API Reference

Class List

AnimComponent

Extends: Component

The Anim Component allows an Entity to playback animations on models and entity properties.

Summary

Properties

activate

If true the first animation will begin playing when the scene is loaded.

baseLayer

Returns the base layer of the state graph.[read only]

playable

Returns whether all component layers are currently playable.[read only]

playing

Plays or pauses all animations in the component.

rootBone

The entity that this anim component should use as the root of the animation hierarchy.

speed

Speed multiplier for animation play back speed.

Methods

addLayer

Adds a new anim component layer to the anim component.

assignAnimation

Associates an animation with a state in the loaded state graph.

findAnimationLayer

Finds a AnimComponentLayer in this component.

getBoolean

Returns a boolean parameter value by name.

getFloat

Returns a float parameter value by name.

getInteger

Returns an integer parameter value by name.

getTrigger

Returns a trigger parameter value by name.

loadStateGraph

Initializes component animation controllers using the provided state graph.

rebind

Rebind all of the components layers.

removeNodeAnimations

Removes animations from a node in the loaded state graph.

removeStateGraph

Removes all layers from the anim component.

reset

Reset all of the components layers and parameters to their initial states.

resetTrigger

Resets the value of a trigger parameter that was defined in the animation components state graph to false.

setBoolean

Sets the value of a boolean parameter that was defined in the animation components state graph.

setFloat

Sets the value of a float parameter that was defined in the animation components state graph.

setInteger

Sets the value of an integer parameter that was defined in the animation components state graph.

setTrigger

Sets the value of a trigger parameter that was defined in the animation components state graph to true.

Inherited

Properties

system

The ComponentSystem used to create this Component.

entity

The Entity that this Component is attached to.

enabled

Enables or disables the component.

Details

Constructor

AnimComponent(system, entity)

Create a new AnimComponent.

Parameters

systemAnimComponentSystem

The ComponentSystem that created this Component.

entityEntity

The Entity that this Component is attached to.

Properties

booleanactivate

If true the first animation will begin playing when the scene is loaded.

AnimComponentLayerbaseLayer

Returns the base layer of the state graph.

[read only]

booleanplayable

Returns whether all component layers are currently playable.

[read only]

booleanplaying

Plays or pauses all animations in the component.

EntityrootBone

The entity that this anim component should use as the root of the animation hierarchy.

numberspeed

Speed multiplier for animation play back speed. 1.0 is playback at normal speed, 0.0 pauses the animation.

Methods

addLayer(name, [weight], [mask], [blendType])

Adds a new anim component layer to the anim component.

Parameters

namestring

The name of the layer to create.

weightnumber

The blending weight of the layer. Defaults to 1.

maskobject[]

A list of paths to bones in the model which should be animated in this layer. If omitted the full model is used. Defaults to null.

blendTypestring

Defines how properties animated by this layer blend with animations of those properties in previous layers. Defaults to pc.ANIM_LAYER_OVERWRITE.

Returns

AnimComponentLayer

The created anim component layer.

assignAnimation(nodeName, animTrack, [layerName], [speed], [loop])

Associates an animation with a state in the loaded state graph. If all states are linked and the AnimComponent#activate value was set to true then the component will begin playing. If no state graph is loaded, a default state graph will be created with a single state based on the provided nodeName parameter.

Parameters

nodeNamestring

The name of the state node that this animation should be associated with.

animTrackobject

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

layerNamestring

The name of the anim component layer to update. If omitted the default layer is used. If no state graph has been previously loaded this parameter is ignored.

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.

findAnimationLayer(name)

Finds a AnimComponentLayer in this component.

Parameters

namestring

The name of the anim component layer to find.

Returns

AnimComponentLayer

Layer.

getBoolean(name)

Returns a boolean parameter value by name.

Parameters

namestring

The name of the boolean to return the value of.

Returns

boolean

A boolean.

getFloat(name)

Returns a float parameter value by name.

Parameters

namestring

The name of the float to return the value of.

Returns

number

A float.

getInteger(name)

Returns an integer parameter value by name.

Parameters

namestring

The name of the integer to return the value of.

Returns

number

An integer.

getTrigger(name)

Returns a trigger parameter value by name.

Parameters

namestring

The name of the trigger to return the value of.

Returns

boolean

A boolean.

loadStateGraph(stateGraph)

Initializes component animation controllers using the provided state graph.

entity.anim.loadStateGraph({
    "layers": [
        {
            "name": layerName,
            "states": [
                {
                    "name": "START",
                    "speed": 1
                },
                {
                    "name": "Initial State",
                    "speed": speed,
                    "loop": loop,
                    "defaultState": true
                }
            ],
            "transitions": [
                {
                    "from": "START",
                    "to": "Initial State"
                }
            ]
        }
    ],
    "parameters": {}
});

Parameters

stateGraphobject

The state graph asset to load into the component. Contains the states, transitions and parameters used to define a complete animation controller.

rebind()

Rebind all of the components layers.

removeNodeAnimations(nodeName, [layerName])

Removes animations from a node in the loaded state graph.

Parameters

nodeNamestring

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

layerNamestring

The name of the anim component layer to update. If omitted the default layer is used.

removeStateGraph()

Removes all layers from the anim component.

reset()

Reset all of the components layers and parameters to their initial states. If a layer was playing before it will continue playing.

resetTrigger(name)

Resets the value of a trigger parameter that was defined in the animation components state graph to false.

Parameters

namestring

The name of the parameter to set.

setBoolean(name, value)

Sets the value of a boolean parameter that was defined in the animation components state graph.

Parameters

namestring

The name of the parameter to set.

valueboolean

The new boolean value to set this parameter to.

setFloat(name, value)

Sets the value of a float parameter that was defined in the animation components state graph.

Parameters

namestring

The name of the parameter to set.

valuenumber

The new float value to set this parameter to.

setInteger(name, value)

Sets the value of an integer parameter that was defined in the animation components state graph.

Parameters

namestring

The name of the parameter to set.

valuenumber

The new integer value to set this parameter to.

setTrigger(name, [singleFrame])

Sets the value of a trigger parameter that was defined in the animation components state graph to true.

Parameters

namestring

The name of the parameter to set.

singleFrameboolean

If true, this trigger will be set back to false at the end of the animation update. Defaults to false.

Inherited

Properties

ComponentSystemsystem

The ComponentSystem used to create this Component.

Entityentity

The Entity that this Component is attached to.

booleanenabled

Enables or disables the component.