Lens Scripting API

    Class AnimationMixer

    Controls playback of animations on the attached SceneObject and its child objects. Please refer to the Playing 3D Animation Guide for setting up and playing animations.

    // PlayAnimation.js
    // Version: 0.0.3
    // Event: Lens Turned On
    // Description: Plays a single animation on an animated mesh. If an AnimationMixer is not set, the script will attempt to find one on the SceneObject.
    // @input Component.AnimationMixer animationMixer
    // @input string animationLayerName = "BaseLayer"
    // @input float animationWeight = 1.0 {"widget":"slider", "min": 0, "max": 1, "step": 0.01}
    // @input float animationStartOffset = 0.0
    // @input int numberOfLoops = -1
    if(!script.animationMixer)
    {
    script.animationMixer = script.getSceneObject().getFirstComponent("Component.AnimationMixer");
    }
    if(script.animationMixer)
    {
    script.animationMixer.setWeight(script.animationLayerName, script.animationWeight);
    script.animationMixer.start(script.animationLayerName, script.animationStartOffset, script.numberOfLoops);
    }

    Hierarchy (View Summary, Expand)

    Index

    Constructors

    Properties

    autoplay: boolean

    Whether this AnimationMixer is set to automatically play animations on start.

    enabled: boolean

    If disabled, the Component will stop enacting its behavior.

    sceneObject: SceneObject

    The scene object this component is on.

    speedRatio: number

    A multiplying value for the speed of all animations being controlled by the AnimationMixer. For example, a value of 2.0 will double animation speed, while a value of 0.5 will cut the speed in half.

    uniqueIdentifier: string

    Methods

    • Destroys the component.

      Returns void

    • Returns a list of names of AnimationLayers in this AnimationMixer.

      Returns string[]

    • Returns the current time (in seconds) of the layer named name.

      Parameters

      • name: string

      Returns number

    • Returns the name of this object's type.

      Returns string

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

      Parameters

      • type: string

      Returns boolean

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

      Parameters

      Returns boolean

    • Pauses animation layers named name, or all layers if name is empty.

      Parameters

      • name: string

      Returns void

    • Rebuild the animation hierarchy by finding all Animation components in the SceneObject and its children.

      Returns void

    • Resumes any paused animation layer with name name, or all layers if name is empty.

      Parameters

      • name: string

      Returns void

    • Sets the weight of any layers with name name.

      Parameters

      • name: string
      • weight: number

      Returns void

    • Starts playing animation layers named name, or all layers if name is empty. The animation will start with an offset of offset seconds. The animation will play cycles times, or loop forever if cycles is -1.

      Parameters

      • name: string
      • offset: number
      • cycles: number

      Returns void

    • Starts playing animation layers named name, or all layers if name is empty. The animation will start with an offset of offset seconds. The animation will play cycles times, or loop forever if cycles is -1. eventCallback will be called after any animation layer finishes playing.

      Parameters

      • name: string
      • offset: number
      • cycles: number
      • eventCallback: (name: string, animationMixer: AnimationMixer) => void

      Returns void

    • Stops any animation layer with name name, or all layers if name is empty.

      Parameters

      • name: string

      Returns void

    MMNEPVFCICPMFPCPTTAAATR