Skip to content

@relu-interactives/spatial-ecs


@relu-interactives/spatial-ecs / components / AnimationComponent

Class: AnimationComponent

Defined in: components/Animation.ts:71

Animation catalog and runtime state for an entity. Combines clips imported from a model with externally added clips, exposes a state machine for named transitions, and is queried each frame by the animation system to advance mixer time.

Remarks

Use the addState / switchState helpers rather than mutating the state machine directly so the animation system observes transitions.

Extends

Constructors

Constructor

ts
new AnimationComponent(options?): AnimationComponent;

Defined in: components/Animation.ts:102

Parameters

ParameterType
optionsAnimationComponentOptions

Returns

AnimationComponent

Overrides

Component.constructor

Properties

PropertyTypeDescriptionDefined in
clipsAnimationClip[]Combined ordered list of clips (model + external) currently loaded.components/Animation.ts:78
clipCatalogAnimationClipCatalogEntry[]Per-clip metadata used by the inspector.components/Animation.ts:80
availableClipsstring[]Display names of clips available for state-machine bindings.components/Animation.ts:82
externalClipSourcesstring[]URLs/paths of external clip sources (saved with the project).components/Animation.ts:84
pausedbooleanWhether playback is currently paused.components/Animation.ts:86
reversebooleanPlay the active clip in reverse.components/Animation.ts:88
timeScalenumberPlayback speed multiplier (1 = real-time).components/Animation.ts:90
crossFadeDurationnumberDefault cross-fade duration in seconds when switching states.components/Animation.ts:92
statesAnimationStateMachine[]All state-machine entries authored on this entity.components/Animation.ts:94
active| AnimationStateMachine | nullState currently being played, or null if none.components/Animation.ts:96
activeStateNamestring | nullName of the active state, or null if none.components/Animation.ts:98
stateManagerAnimationStateManagerManager that drives state transitions; mutate via addState/switchState.components/Animation.ts:100

Methods

setModelClips()

ts
setModelClips(clips): void;

Defined in: components/Animation.ts:234

Parameters

ParameterType
clipsAnimationClip[]

Returns

void


setImportedClips()

ts
setImportedClips(clips): void;

Defined in: components/Animation.ts:239

Parameters

ParameterType
clipsAnimationClip[] | ImportedClipEntry[]

Returns

void


setExternalClipSources()

ts
setExternalClipSources(sources): void;

Defined in: components/Animation.ts:276

Parameters

ParameterType
sourcesstring[]

Returns

void


addState()

ts
addState(
   name, 
   clipRef, 
   loop?): 
  | AnimationStateMachine
  | null;

Defined in: components/Animation.ts:301

Parameters

ParameterTypeDefault value
namestringundefined
clipRefstringundefined
loopbooleanfalse

Returns

| AnimationStateMachine | null


setStates()

ts
setStates(states): void;

Defined in: components/Animation.ts:316

Parameters

ParameterType
states{ name: string; clip: string; clipId?: string; loop?: boolean; }[]

Returns

void


getStateConfigs()

ts
getStateConfigs(): {
  name: string;
  clip: string;
  clipId: string | null;
  loop: boolean;
}[];

Defined in: components/Animation.ts:343

Returns

{ name: string; clip: string; clipId: string | null; loop: boolean; }[]


setActiveState()

ts
setActiveState(name, autoPlay?): boolean;

Defined in: components/Animation.ts:352

Parameters

ParameterTypeDefault value
namestring | nullundefined
autoPlaybooleantrue

Returns

boolean


removeState()

ts
removeState(name): boolean;

Defined in: components/Animation.ts:363

Parameters

ParameterType
namestring

Returns

boolean


switchState()

ts
switchState(name, autoPlay?): boolean;

Defined in: components/Animation.ts:371

Parameters

ParameterTypeDefault value
namestringundefined
autoPlaybooleantrue

Returns

boolean


playState()

ts
playState(name?): boolean;

Defined in: components/Animation.ts:382

Parameters

ParameterType
name?string

Returns

boolean


pauseState()

ts
pauseState(name?): boolean;

Defined in: components/Animation.ts:393

Parameters

ParameterType
name?string

Returns

boolean


stopState()

ts
stopState(name?): boolean;

Defined in: components/Animation.ts:404

Parameters

ParameterType
name?string

Returns

boolean