RSX Code Reference
    Preparing search index...

    Class Animation

    The Animation components handles animation playback for SceneObject. It takes one or multiple animation clips as input and evaluates them every animation update tick depending on set properties. The evaluated data is used by the animation system to update skeletal animation and morphshapes and by the main thread for updating transforms and generic data fields.

    The animation system supports blending multiple animation clips together through AnimationLayer and supports crossfading between clips. AnimationLayer are directly created on the Animation component and can be masked to only affect specfic bones of a skeleton through SkeletonMask. When compositing layers, each layer is blended downwards into the base layer (layer 0) based on the layer opacity and blend mode.


    @inspectableField([Array, Number])
    public objectCounts: number[] = [1, 2, 3];

    @inspectableField(Number)
    @description("Sets the default size of all the interactive gizmos used to modify a scene object's transform.")
    @defaultValue(1)
    @slider(0.01, 2)
    public objectSize: number = 1;

    Hierarchy (View Summary)

    Index
    propertySuffixInfos: Map<string, AnimationPropertySuffixInfo>

    Contains mapping for a suffix used by property paths used for curve identifiers, to their index and type.

    • get active(): boolean

      Activates or deactivates the component.

      Returns boolean

      The returned active state also accounts for the active state of the parent SceneObject.

    • set active(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • get bounds(): Immutable<AABox>

      Determines bounds that will be used for animation and mesh culling. Only relevant if setUseBounds() is set to true.

      Returns Immutable<AABox>

    • set bounds(value: Immutable<AABox>): void

      Parameters

      Returns void

    • get clipCount(): number

      Returns the total number of animation clips influencing this animation.

      Returns number

    • get defaultClip(): AnimationClip

      Determines the default clip to play as soon as the component is enabled. If more control over playing clips is needed use the play(), blend() and crossFade() methods to queue clips for playback manually, and setState() method for modify their states individually.

      Returns AnimationClip

    • set defaultClip(value: AnimationClip): void

      Determines the default clip to play as soon as the component is enabled. If more control over playing clips is needed use the play(), blend() and crossFade() methods to queue clips for playback manually, and setState() method for modify their states individually.

      Parameters

      Returns void

    • get editorMetaData(): Settings

      Get the editor meta data.

      Returns Settings

      The API is only valid in the editor.

    • get isActiveSelf(): boolean

      Determines whether the component itself is active, without accounting for the active state of the parent scene object.

      Returns boolean

    • get isDestroyed(): boolean

      Determines if the object has been destroyed.

      Returns boolean

    • get isEnableCull(): boolean

      Enables or disables culling of the animation when out of view. Culled animation will not be evaluated.

      Returns boolean

    • set isEnableCull(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • get isPlaying(): boolean

      Checks if any animation clips are currently playing.

      Returns boolean

    • get isRunning(): boolean

      Determines if the component is currently active, enabled and running.

      Returns boolean

    • get isUsingBounds(): boolean

      Determines should animation bounds be used for visibility determination (culling). If false the bounds of the mesh attached to the relevant Renderable component will be used instead.

      Returns boolean

    • set isUsingBounds(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • get primaryClip(): AnimationClip

      Gets the primary playing clip.

      Returns AnimationClip

    • get priority(): number

      The signed execution priority of the component.

      Determines order of execution of this component in relation to other components, higher priorities will execute earlier. The priority value determines the order of initialize, enable and update calls. Valid priorities are in the range [-100...100], other priorities are reserved for internal use.

      The priority should not be modified after onCreate has been called.

      The default priority for user implement components is -10. BuiltinComponent have a default priority of 0. However, instances that have dependencies or are a dependency to another component might have non zero default priorities. For example, the Camera component has a default priority of 50 as other components may depend on the camera being initialized early. The Rigidbody component has a default priority of 22 and Joint components have a priority of 20 as the joint depends on fully initialized rigid bodies.

      Returns number

      If two components have the same priority, the order of execution is undefined, but deterministic as the system uses identifiers such as the internal type ID and UUID to guaranteed stable ordering.

    • set priority(value: number): void

      Parameters

      • value: number

      Returns void

    • get speed(): number

      Determines the speed for all animations and all layers. The default value is 1.0f. Use negative values to play-back in reverse.

      Returns number

    • set speed(value: number): void

      Parameters

      • value: number

      Returns void

    • get uuid(): UUID

      Returns a universally unique identifier that persists scene save/load.

      Returns UUID

    • Blend multiple animation clips between each other using linear interpolation.

      Parameters

      • info: Immutable<Blend1DInfo>

        Information about the clips to blend. Clip positions must be sorted from lowest to highest.

      • t: number

        Parameter that controls the blending. Range depends on the positions of the provided animation clips.

      • Optionallayer: AnimationLayer

        The layer to play the blend on. Pass null to play the clip on the main layer.

      Returns void

      To update an existing blend, call the same method again, passing the identical info object with an updated t. RSX will recongize that the blend is already setup and only update the clip weights.

    • Blend four animation clips between each other using bilinear interpolation.

      Parameters

      • info: Immutable<Blend2DInfo>

        Information about the clips to blend.

      • t: Immutable<Vector2>

        Parameter that controls the blending, in range [(0, 0), (1, 1)]. t = (0, 0) means top left animation has full influence, t = (1, 0) means top right animation has full influence, t = (0, 1) means bottom left animation has full influence, t = (1,

        1. means bottom right animation has full influence.
      • Optionallayer: AnimationLayer

        The layer to play the blend on. Pass null to play the clip on the main layer.

      Returns void

      To update an existing blend, call the same method again, passing the identical info object with an updated t. RSX will recongize that the blend is already setup and only update the clip weights.

    • Plays the specified animation clip on top of the animation currently playing in the main layer. Multiple such clips can be playing at once, as long as you ensure each is given its own layer. Each animation can also have a weight that determines how much it influences the main animation.

      Parameters

      • clip: AnimationClip | ResourceHandle<AnimationClip>

        Clip to additively blend. Must contain additive animation curves.

      • weight: number

        Determines how much of an effect will the blended animation have on the final output. In range [0, 1].

      • OptionalfadeLength: number

        Applies the blend over a specified time period, increasing the weight as the time passes. Set to zero to blend immediately. In seconds.

      • Optionallayer: AnimationLayer

        Layer to play the clip in. Multiple additive clips can be playing at once in separate layers and each layer has its own weight.

      Returns void

    • Blend multiple animation clips together to form character locomotion.

      Parameters

      • info: Immutable<LocomotionBlendInfo>

        Information about the clips to blend.

      • forwardBack: number

        Controls the forward/backward movement of the player in range [-1 ... 1]. Pass 1 for forward, 0 for idle, -1 for backward.

      • leftRight: number

        Controls the left/right movement of the player in range [-1...1]. Pass 1 for left, 0 for idle, -1 for right.

      • Optionallayer: AnimationLayer

        The layer to play the blend on. Pass null to play the clip on the main layer.

      Returns void

      To update an existing blend, call the same method again, passing the identical info object with an updated t. RSX will recongize that the blend is already setup and only update the clip weights.

    • Virtual

      Calculates bounds of the visible content for this component.

      Returns { box: AABox; sphere: Sphere }

      An object with the bounding box and bounding sphere or null, if the component has no bounds.

    • Creates a new layer to be used with this animation.

      Returns AnimationLayer

      Layers are tied to the animation that created it.

    • Fades the specified animation clip in, while fading other playing animation out, over the specified time period.

      Parameters

      Returns void

      true if the animation was started.

    • Destroys the component, removing it from its scene object and stopping component updates.

      Parameters

      • Optionalimmediate: boolean

        If true the component will be fully destroyed immediately. This means that objects that are still referencing this component might fail. Normally destruction is delayed until the end of the frame to give other objects a chance to stop using it.

      Returns void

    • Returns the current time of the currently playing editor animation clip.

      Returns number

      Time in seconds.

    • Allows the to play an animation clip in the editor when no scene is simulating. This form of animation playback is limited as you have no control over clip properties, and features like blending, cross fade or animation events are not supported.

      Parameters

      • clip: AnimationClip

        Animation clip to play.

      • startTime: number

        Time to start playing at, in seconds.

      • Optionalfreeze: boolean

        If true, only the frame at the specified time will be shown, without advancing the animation.

      Returns void

      It is required to manually call updateFloatProperties in order to apply evaluated animation data to relevant float properties where necessary.

      If internal curves change, call refreshClipMappings whenever the curves internal to the animation clip change. This should be called before the call toupdateFloatProperties.

    • Stops playback of animation whose playback what started using editorPlay.

      Returns void

    • Returns one of the animation clips influencing this animation.

      Parameters

      • index: number

      Returns AnimationClip

      Animation clip at the specified index, or null if the index is out of range.

    • Gets the latest available evaluated local pose for the specified bone.

      Parameters

      • boneIndex: number

        The index of the bone to get the pose for

      Returns Matrix4

      The local transform of the specified bone if successful or null if not

    • Gets the latest available evaluated local pose for the specified bone.

      Parameters

      • boneName: string

      Returns Matrix4

      The local transform of the specified bone if successful or null if not

    • Attempts to retrieve the latest available evaluated pose from the AnimationManager. The number of transforms coincides with the number of bones on the Skeleton when the animation was evaluated.

      Returns Matrix4[]

      The pose data, or an empty optional if no pose data was found.

      The pose currently only includes skeleton poses. If the animation is not using a Skeleton the method will return false.

    • Gets an empty or idle layer.

      Returns AnimationLayer

      The first empty or idle layer found.

      An empty or idle layer is a layer without any clips or with all clips stopped, or with all clips paused, or with all clips with a weight of 0.

    • Retrieves an evaluated value for a generic curve with the specified index.

      Parameters

      • curveIdx: number

        The curve index referencing a set of curves from the first playing animation clip. Generic curves from all other clips are ignored.

      Returns number

      Value of the generic curve. Only valid if the method return true if the value was retrieved successfully. The method might fail if animation update didn't yet have a chance to execute and values are not yet available, or if the animation clip changed since the last frame (the last problem can be avoided by ensuring to read the curve values before changing the clip).

    • Virtual

      Returns the bounds of the visible content for this component in local space, i.e. relative to the scene object's transform.

      Returns { box: AABox; sphere: Sphere }

      An object with the bounding box and bounding sphere or null, if the component has no bounds.

    • Gets the current weight of a single morph channel, determining how much of it to apply on top of the base mesh.

      Parameters

      • name: string

        Name of the morph channel to modify. This depends on the mesh the animation is currently animating.

      Returns number

      Morph channel weight.

    • Calls a parameterless method with the specified name, on the component.

      Parameters

      • name: string

        Name of the method to call.

      Returns boolean

      true if the method was invoked.

    • Virtual

      Called once when the component has been created.

      Returns void

      Called regardless of the state the component is in.

    • Virtual

      Called once just before the component is destroyed.

      Returns void

      Called regardless of the state the component is in.

    • Virtual

      Called every time a component is placed into the Stopped state.

      Returns void

      This method may be called during component destruction, if the component wasn't already in ScenePlayState.Stopped state during destruction. When called during destruction, it is called before onDestroy.

    • Virtual

      Called every time a component leaves the ScenePlayState.Stopped state.

      Returns void

      This method might be called during component creation, if the requirements for leaving the stopped state are met. One such case would be a component class that has the runInEditor attribute. When called during creation it is called after onInitialize.

    • Called at fixed time intervals (e.g. 60 times per frame). Only called if the component is in ScenePlayState.Playing state.

      Returns void

      RSX uses the fixed update to perform updates to sub-systems such as physics. Only implement this method if your logic depends on fixed updates (e.g. at 30hz) for stability.

    • Virtual

      Called once when the component first leaves the ScenePlayState.Stopped state.

      Returns void

      This method might be called during component creation, if the requirements for leaving the stopped state are met. One such case would be a component class that has the runInEditor attribute. When called during creation it is called after onCreate.

    • Virtual

      Called once per frame, after all other components received their onUpdate invocation. Only called if the component is in ScenePlayState.Playing state.

      Returns void

      This method should only be implemented if your component needs logic that implements on other component or SceneObject changes performend in onUpdate. An example could be a camera controller logic that updates in response to changes to the object that is being tracked.

    • Virtual

      Called when the script domain has been refreshed or when the component is initialized. During initialization it is called after onInitialize but before onEnable.

      Returns void

      This API will not be called in a deployment build.

    • Virtual

      Called once per frame. Only called if the component is in ScenePlayState.Playing state.

      Returns void

    • Moves the layer to be right below the beforeLayer.

      Parameters

      Returns boolean

      True upon success.

      The main layer cannot be moved.

    • Moves the layer to the top.

      Parameters

      Returns boolean

      True upon success.

      The main layer cannot be moved.

    • Pauses all animation clips on all layers.

      Parameters

      • isPaused: boolean

      Returns number

      The number of clips modified.

    • Pauses the all animation clips on the specified layer.

      Parameters

      Returns number

      The number of clips modified.

    • Rebuilds internal curve -> property mapping about the primary playing animation clip. This mapping allows the animation component to know which property to assign which values from an animation curve. This should be called whenever playback for a new clip starts, or when clip curves change.

      Returns void

    • Removes the specified layer from this animation.

      Parameters

      Returns boolean

      Layers are tied to the animation that created it.

    • Changes a weight of a single morph channel, determining how much of it to apply on top of the base mesh.

      Parameters

      • name: string

        Name of the morph channel to modify. This depends on the mesh the animation is currently animating.

      • weight: number

        Weight that determines how much of the channel to apply to the mesh, in range [0, 1].

      Returns void

    • Sets the primary playing clip. The component must be in play state or this method will fail.

      Parameters

      Returns boolean

      true if the primary clip was set

      The primary playing clip is able to evaluate generic animation curves that modify component properties as well as sub scene objects.

    • Determines the speed for all animations on the specified layer.

      Parameters

      Returns void

      The default value is 1.0f. Use negative values to play-back in reverse. The default value for new clips on the layer can be controlled using the AnimationLayer::DefaultSpeed value.

    • Registers the coroutine for the specified component using the provided args as arguments.

      Type Parameters

      Parameters

      • coroutine: T

        The coroutine.

      • ...args: Parameters<T>

      Returns boolean

      true if the coroutine was registered.

      The coroutine will be called for the first time when the coroutine subsystem runs for update events. There is no guarantee with regards to the order of how coroutines are invoked. Coroutines are a great way for time-deferred or delayed system. To implement a coroutine simply add a generator method to your component and register it as coroutine:

      		public *myCoroutine(text:string)
      {
      const endTime:number = Time.realElapsed + 3;

      while(Time.realElapsed < endTime)
      {
      yield true;
      }

      Debug.log("This code will be invoked after 3 seconds with the text=" + text);
      }

      To register the function simply call

      		this.startCoroutine(this.myCoroutine, "Hello World!");
      

      The function will be invoked once the coroutine runs. The coroutine function can yield the program control flow by using the keyword yield. The coroutine will then stop execution at that point, and pick up the execution in the next update event, right after the yield keyword that caused the coroutine to pause.

      With helper functions such as waitForSeconds or waitForAsyncOp it is easy to create coroutines that pause for a set time interval.

    • Registers the coroutine for the specified component using the provided args as arguments.

      Type Parameters

      Parameters

      • coroutine: T

        The coroutine.

      • ...args: Parameters<T>

      Returns boolean

      true if the coroutine was registered.

      The coroutine will be called for the first time when the coroutine subsystem runs for fixedUpdate events. There is no guarantee with regards to the order of how coroutines are invoked. Coroutines are a great way for time-deferred or delayed system. To implement a coroutine simply add a generator method to your component and register it as coroutine:

      		public *myCoroutine(text:string)
      {
      const endTime:number = Time.realElapsed + 3;

      while(Time.realElapsed < endTime)
      {
      yield true;
      }

      Debug.log("This code will be invoked after 3 seconds!");
      }

      To register the function simply call

      		this.startCoroutine(this.myCoroutine, "Hello World!");
      

      The function will be invoked once the coroutine runs. The coroutine function can yield the program control flow by using the keyword yield. The coroutine will then stop execution at that point, and pick up the execution in the next fixedUpdate event, right after the yield keyword that caused the coroutine to pause.

      With helper functions such as waitForSeconds or waitForAsyncOp it is easy to create coroutines that pause for a set time interval.

    • Stops playing all animations on the provided layer.

      Parameters

      Returns void

    • Stops playing all animations.

      Returns void

    • Stops all coroutines for the specified component.

      Returns void

      This API is only available for components that are registered in a scene.

    • Preview mode allows certain operations on the component to be allowed (like basic animation playback), even when the component is not actively running. This is intended for use primarily by the animation editor. Preview mode ends automatically when the component is enabled (i.e. starts running normally), or when explicitly disabled. Returns true if the preview mode was enabled (which could fail if the component is currently running).

      Parameters

      • enabled: boolean

      Returns boolean

    • Returns a string representation of an object.

      Returns string

    • Updates generic float properties on relevant objects, based on the most recently evaluated animation curve values.

      Returns void

    • Searches the scene object hierarchy to find a property at the given path.

      Parameters

      • root: SceneObject

        Root scene object to which the path is relative to.

      • path: string

        Path to the property, where each element of the path is separated with "/".

                 Path elements prefixed with "!" signify names of child scene objects (first one relative to
                 `root`. Name of the root element should not be included in the path.
        
                 Path element prefixed with ":" signify names of components. If a path doesn't have a
                 component element, it is assumed the field is relative to the scene object itself (only
                 "position", "rotation" and "scale" fields are supported in such case). Only one component
                 path element per path is allowed.
        
                 Path entries with no prefix are considered regular interop object fields. Each path must have
                 at least one such entry.
        
                 A field path can be followed by an indexer [n] where n is a zero-based index. Such paths
                 are assumed to be referencing an index within an array or a list.
        
                 A field path can also be followed by a suffix (after the indexer, if any) separated from the
                 path name with ".". This suffix is not parsed internally, but will be returned as
                 `suffix`.
        
                 Path examples:
                     :MyComponent/myInt (path to myInt variable on a component attached to the root object)
                     :MyComponent/myArray[0] (path to first element of myArray on the same component as above)
                     !childSO/:MyComponent/myInt (path to myInt variable on a child scene object)
                     !childSO/position (path to the scene object position)
                     :MyComponent/myVector.z (path to the z component of myVector on the root object)
        
      • OptionalgenericCurvesOnly: boolean

        Return properties for generic animation curvers.

      Returns {
          inspectableProperty: InspectableProperty;
          suffix: string;
          transformType?: "position" | "scale" | "rotation";
      }

      Object.

      • inspectableProperty: InspectableProperty

        If found, an object you can use for setting and getting the value from the property.

      • suffix: string

        Suffix of the last field entry, if it has any - including the suffix separator '.'.

      • OptionaltransformType?: "position" | "scale" | "rotation"

        If the property is part of a transform, contains the type of the transform.

    • Locates a rsx object by its sceneRuntimeID and UUID.

      Parameters

      • sceneRuntimeID: number

        The runtime ID of the SceneInstance of the object.

      • uuid: Const<UUID>

        The UUID of the object to retrieve.

      Returns SceneNode

      The object or null if no object with given sceneRuntimeID and uuid has been registered