Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SkeletalAnimation

Skeletal animation component, offers the following features on top of Animation:

  • Choice between baked animation and real-time calculation, to leverage efficiency and expressiveness.
  • Joint socket system: Create any socket node directly under the animation component root node, find your target joint and register both to the socket list, so that the socket node would be in-sync with the joint.

Hierarchy

Index

Properties

Protected _clips

_clips: (null | AnimationClip)[] = []

Protected _crossFade

_crossFade: CrossFade = new CrossFade()

Protected _defaultClip

_defaultClip: AnimationClip | null = null

Protected _nameToState

_nameToState: Record<string, AnimationState> = createMap(true)

Protected _sockets

_sockets: Socket[] = []

Protected _useBakedAnimation

_useBakedAnimation: boolean = true

playOnLoad

playOnLoad: boolean = false

Whether the default clip should get into playing when this components starts. Note, this field takes no effect if crossFade() or play() has been called before this component starts.

Static EventType

EventType: EnumAlias<typeof EventType> = EventType

Static Socket

Socket: Socket = Socket

Accessors

clips

defaultClip

sockets

useBakedAnimation

  • get useBakedAnimation(): boolean
  • set useBakedAnimation(val: boolean): void
  • Whether to bake animations. Default to true,
    which substantially increases performance while making all animations completely fixed.
    Dynamically changing this property will take effect when playing the next animation clip.

    Returns boolean

  • Whether to bake animations. Default to true,
    which substantially increases performance while making all animations completely fixed.
    Dynamically changing this property will take effect when playing the next animation clip.

    Parameters

    • val: boolean

    Returns void

Methods

Protected createState

Protected doCreateState

addClip

createSocket

  • createSocket(path: string): null | Node

createState

crossFade

  • crossFade(name: string, duration?: number): void
  • Smoothly switch to play specified animation state.

    zn

    平滑地切换到指定动画状态。

    Parameters

    • name: string

      The name of the animation to switch to

    • Default value duration: number = 0.3

      The duration of the cross fade, default value is 0.3s

    Returns void

getAnimationState

getState

off

  • off(type: EventType, callback?: undefined | ((...any: any[]) => void), thisArg?: any): void
  • Unregister animation event callback.

    example
    // unregister event to all animation
    animation.off('play', this.onPlay, this);

    Parameters

    • type: EventType

      The event type to unregister

    • Optional callback: undefined | ((...any: any[]) => void)

      The callback to unregister

    • Optional thisArg: any

    Returns void

on

  • on<TFunction>(type: EventType, callback: TFunction, thisArg?: any, once?: undefined | false | true): any
  • Register animation event callback. The event arguments will provide the AnimationState which emit the event. When play an animation, will auto register the event callback to the AnimationState, and unregister the event callback from the AnimationState when animation stopped.

    example
    onPlay: function (type, state) {
        // callback
    }
    // register event to all animation
    animation.on('play', this.onPlay, this);

    Type parameters

    • TFunction: (...any: any[]) => void

    Parameters

    • type: EventType

      The event type to listen to

    • callback: TFunction

      The callback when event triggered

    • Optional thisArg: any
    • Optional once: undefined | false | true

    Returns any

    The registered callback

onDestroy

  • onDestroy(): void

onDisable

  • onDisable(): void

onEnable

  • onEnable(): void

onLoad

  • onLoad(): void

once

  • once<TFunction>(type: EventType, callback: TFunction, thisArg?: any): any

pause

  • pause(): void

play

  • play(name?: undefined | string): void

querySockets

  • querySockets(): string[]

rebuildSocketAnimations

  • rebuildSocketAnimations(): void

removeClip

  • removeClip(clip: AnimationClip, force?: undefined | false | true): void
  • Remove clip from the animation list. This will remove the clip and any animation states based on it.
    If there are animation states depend on the clip are playing or clip is defaultClip, it will not delete the clip.
    But if force is true, then will always remove the clip and any animation states based on it. If clip is defaultClip, defaultClip will be reset to null

    deprecated

    please use removeState

    Parameters

    • clip: AnimationClip
    • Optional force: undefined | false | true

      If force is true, then will always remove the clip and any animation states based on it.

    Returns void

removeState

  • removeState(name: string): void

resume

  • resume(): void

start

  • start(): void

stop

  • stop(): void

Generated using TypeDoc