Skip to main content

AnimationAsset

Class

Represents animation data.

  • Available on all platforms
Platform details: Snapchat, SPECS, Camera Kit Web, Camera Kit Mobile fully supported.

Platform details

  • Snapchat — Fully supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

Since Lens Scripting v253

Represents animation data. Can have multiple AnimationPropertyLayers. Used in AnimationClip.

Index

Remarks

AnimationAssets themselves do not handle playing or orchestrating animations. This is left to the AnimationPlayer component to handle.

Example

// @input Asset.AnimationAsset animAsset
const startEventName = 'animStarted';
const startTimestamp = 0;
const e = script.animAsset.createEvent(startEventName, startTimestamp);
const endEventName = 'animEnded';
const endTimestamp = script.animAsset.duration;
script.animAsset.createEvent(endEventName, endTimestamp);

Extends

Properties

duration

readonly duration: number

Animation duration in seconds.

Since

Lens Scripting Version 253


fps

readonly fps: number

Denotes how many key frames this animation was sampled at.

Since

Lens Scripting Version 253


name

name: string

The name of the Asset in Lens Studio.

Default Value

""

Inherited from

Asset.name


uniqueIdentifier

readonly uniqueIdentifier: string

Since

Lens Scripting Version 176

Inherited from

Asset.uniqueIdentifier

Methods

addLayer()

addLayer(layerName, layer): void

Adds AnimationPropertyLayer to Animation asset.

Parameters

ParameterType
layerNamestring
layerAnimationPropertyLayer

Returns

void

Since

Lens Scripting Version 253


clearLayers()

clearLayers(): void

Delete all the AnimationPropertyLayer in this AnimationAsset.

Returns

void

Since

Lens Scripting Version 253


create()

static create(): AnimationAsset

Create new animation asset.

Returns

AnimationAsset

Since

Lens Scripting Version 333


createEvent()

createEvent(eventName, time): AnimationPropertyEventRegistration

Creates an event that will be triggered at a given time of this animation asset.

Parameters

ParameterType
eventNamestring
timenumber

Returns

AnimationPropertyEventRegistration

Since

Lens Scripting Version 265


deleteEvent()

deleteEvent(registration?): void

Deletes an event that will be triggered at a given time.

Parameters

ParameterType
registration?AnimationPropertyEventRegistration

Returns

void

Since

Lens Scripting Version 265


deleteLayer()

deleteLayer(layerName): void

Delete the AnimationPropertyLayer named layerName.

Parameters

ParameterType
layerNamestring

Returns

void

Since

Lens Scripting Version 253


getLayer()

getLayer(layerName): AnimationPropertyLayer

Retrieves an animation associated with a particular object.

Parameters

ParameterType
layerNamestring

Returns

AnimationPropertyLayer

Since

Lens Scripting Version 253


getTypeName()

static getTypeName(): TypeName<AnimationAsset>

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<AnimationAsset>

Since

Lens Scripting Version 253

Overrides

Asset.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

Asset.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

Asset.isOfType


isSame()

isSame(other): boolean

Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

Asset.isSame

Nested types

Variables

VariableDescription
selfLayerNameSpecial layer name that resolves to the SceneObject the AnimationPlayer is attached to, allowing animations to work regardless of the SceneObject's name.