# Abstract Class: MotionManager<Motion, MotionSpec> (/pixi-vn-live2d/core/classes/MotionManager)



Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3373

Handles the motion playback for Live2D models.
Responsible for loading, playing, and managing motion states and audio.

## Emits [#emits]

[MotionManagerEvents](/pixi-vn-live2d/core/interfaces/MotionManagerEvents)

## Extends [#extends]

* `EventEmitter`

## Extended by [#extended-by]

* [`CubismLegacyMotionManager`](/pixi-vn-live2d/core/classes/CubismLegacyMotionManager)
* [`CubismMotionManager`](/pixi-vn-live2d/core/classes/CubismMotionManager)

## Type Parameters [#type-parameters]

### Motion [#motion]

`Motion` = `unknown`

### MotionSpec [#motionspec]

`MotionSpec` = `unknown`

## Constructors [#constructors]

### Constructor [#constructor]

\> `protected` **new MotionManager**\<`Motion`, `MotionSpec`>(`parent`): `MotionManager`\<`Motion`, `MotionSpec`>

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3459

Constructor for MotionManager.

#### Parameters [#parameters]

##### parent [#parent]

[`InternalModel`](/pixi-vn-live2d/core/classes/InternalModel)

The parent InternalModel.

#### Returns [#returns]

`MotionManager`\<`Motion`, `MotionSpec`>

#### Overrides [#overrides]

`EventEmitter.constructor`

## Properties [#properties]

### currentAnalyzer? [#currentanalyzer]

\> `optional` **currentAnalyzer?**: `AnalyserNode`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3434

Analyzer element for the current sound being played.

***

### currentAudio? [#currentaudio]

\> `optional` **currentAudio?**: `Sound`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3429

Audio element of the current motion if a sound file is defined with it.

***

### currentContext? [#currentcontext]

\> `optional` **currentContext?**: `AudioContext`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3439

Context element for the current sound being played.

***

### definitions [#definitions]

\> `abstract` `readonly` **definitions**: `Partial`\<`Record`\<`string`, `MotionSpec`\[]>>

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3384

Motion definitions copied from ModelSettings.

***

### destroyed [#destroyed]

\> **destroyed**: `boolean`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3449

Flags whether the instance has been destroyed.

***

### expressionManager? [#expressionmanager]

\> `abstract` `optional` **expressionManager?**: [`ExpressionManager`](/pixi-vn-live2d/core/classes/ExpressionManager)\<`unknown`, `unknown`>

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3406

Expression manager for handling model expressions.
Can be undefined if the settings define no expression.

***

### groups [#groups]

\> `abstract` `readonly` **groups**: `object`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3390

Motion groups with specific internal usages. Includes at least the 'idle' field.

#### idle [#idle]

\> **idle**: `string`

***

### motionDataType [#motiondatatype]

\> `abstract` `readonly` **motionDataType**: `"json"` | `"arraybuffer"`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3399

Indicates the content type of the motion files, varies in different Cubism versions.
Used as `xhr.responseType`.

***

### motionGroups [#motiongroups]

\> **motionGroups**: `Partial`\<`Record`\<`string`, (`Motion` | `undefined` | `null`)\[]>>

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3419

The Motions. The structure is the same as [definitions](#definitions), initially each group contains
an empty array, which means all motions will be `undefined`. When a Motion has been loaded,
it'll fill the place in which it should be; when it fails to load, the place will be filled
with `null`.

***

### parent [#parent-1]

\> **parent**: [`InternalModel`](/pixi-vn-live2d/core/classes/InternalModel)

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3454

Reference to the parent InternalModel.

***

### playing [#playing]

\> **playing**: `boolean`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3444

Flags whether there is a motion currently playing.

***

### settings [#settings]

\> `readonly` **settings**: [`ModelSettings`](/pixi-vn-live2d/core/classes/ModelSettings)

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3411

The ModelSettings reference.

***

### state [#state]

\> **state**: [`MotionState`](/pixi-vn-live2d/core/classes/MotionState)

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3424

Maintains the state of this MotionManager.

***

### tag [#tag]

\> **tag**: `string`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3378

Tag for logging.

***

### prefixed [#prefixed]

\> `static` **prefixed**: `string` | `boolean`

Defined in: node_modules/eventemitter3/index.d.ts:9

#### Inherited from [#inherited-from]

`EventEmitter.prefixed`

## Methods [#methods]

### \_startMotion() [#_startmotion]

\> `abstract` `protected` **\_startMotion**(`motion`, `onFinish?`, `ignoreParamIds?`, `loop?`): `number`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3613

Starts the Motion.

#### Parameters [#parameters-1]

##### motion [#motion-1]

`Motion`

The Motion to start.

##### onFinish? [#onfinish]

(`motion`) => `void`

Optional callback when finished.

##### ignoreParamIds? [#ignoreparamids]

`string`\[]

The ids to be ignored.

##### loop? [#loop]

`boolean`

Whether the motion should loop.

#### Returns [#returns-1]

`number`

An ID or token for the motion.

***

### \_stopAllMotions() [#_stopallmotions]

\> `abstract` `protected` **\_stopAllMotions**(): `void`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3619

Stops all playing motions.

#### Returns [#returns-2]

`void`

***

### addListener() [#addlistener]

\> **addListener**\<`T`>(`event`, `fn`, `context?`): `this`

Defined in: node_modules/eventemitter3/index.d.ts:45

#### Type Parameters [#type-parameters-1]

##### T [#t]

`T` *extends* `string` | `symbol`

#### Parameters [#parameters-2]

##### event [#event]

`T`

##### fn [#fn]

(...`args`) => `void`

##### context? [#context]

`any`

#### Returns [#returns-3]

`this`

#### Inherited from [#inherited-from-1]

`EventEmitter.addListener`

***

### createMotion() [#createmotion]

\> `abstract` **createMotion**(`data`, `group`, `definition`): `Motion`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3579

Creates a Motion from the data.

#### Parameters [#parameters-3]

##### data [#data]

`object` | `ArrayBuffer`

Content of the motion file. The format must be consistent with [MotionManager#motionDataType](#motiondatatype).

##### group [#group]

`string`

The motion group.

##### definition [#definition]

`MotionSpec`

The motion definition.

#### Returns [#returns-4]

`Motion`

The created Motion.

***

### destroy() [#destroy]

\> **destroy**(): `void`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3565

Destroys the instance and releases all resources.

#### Returns [#returns-5]

`void`

#### Emits [#emits-1]

[MotionManagerEvents.destroy](/pixi-vn-live2d/core/interfaces/MotionManagerEvents#destroy)

***

### emit() [#emit]

\> **emit**\<`T`>(`event`, ...`args`): `boolean`

Defined in: node_modules/eventemitter3/index.d.ts:32

Calls each of the listeners registered for a given event.

#### Type Parameters [#type-parameters-2]

##### T [#t-1]

`T` *extends* `string` | `symbol`

#### Parameters [#parameters-4]

##### event [#event-1]

`T`

##### args [#args]

...`any`\[]

#### Returns [#returns-6]

`boolean`

#### Inherited from [#inherited-from-2]

`EventEmitter.emit`

***

### eventNames() [#eventnames]

\> **eventNames**(): (`string` | `symbol`)\[]

Defined in: node_modules/eventemitter3/index.d.ts:15

Return an array listing the events for which the emitter has registered
listeners.

#### Returns [#returns-7]

(`string` | `symbol`)\[]

#### Inherited from [#inherited-from-3]

`EventEmitter.eventNames`

***

### getMotionAndApplyExpression() [#getmotionandapplyexpression]

\> `protected` **getMotionAndApplyExpression**(`group`, `index`, `expression?`): `Promise`\<`unknown`>

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3637

Loads a motion and applies the given expression with FORCE priority.

#### Parameters [#parameters-5]

##### group [#group-1]

`string`

The motion group.

##### index [#index]

`number`

The motion index.

##### expression? [#expression]

`string` | `number`

Expression to apply (optional).

#### Returns [#returns-8]

`Promise`\<`unknown`>

The loaded motion, or null if not started.

***

### getMotionFile() [#getmotionfile]

\> `abstract` **getMotionFile**(`definition`): `string`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3586

Retrieves the motion's file path by its definition.

#### Parameters [#parameters-6]

##### definition [#definition-1]

`MotionSpec`

Motion definition.

#### Returns [#returns-9]

`string`

The file path extracted from the given definition. Not resolved.

***

### getMotionName() [#getmotionname]

\> `abstract` `protected` **getMotionName**(`definition`): `string`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3594

Retrieves the motion's name by its definition.

#### Parameters [#parameters-7]

##### definition [#definition-2]

`MotionSpec`

Motion definition.

#### Returns [#returns-10]

`string`

The motion's name.

***

### getSoundFile() [#getsoundfile]

\> `abstract` `protected` **getSoundFile**(`definition`): `string` | `undefined`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3602

Retrieves the motion's sound file by its definition.

#### Parameters [#parameters-8]

##### definition [#definition-3]

`MotionSpec`

Motion definition.

#### Returns [#returns-11]

`string` | `undefined`

The motion's sound file, or undefined.

***

### init() [#init]

\> `protected` **init**(`options?`): `void`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3464

Should be called in the constructor of derived class to initialize options and setup motions.

#### Parameters [#parameters-9]

##### options? [#options]

[`MotionManagerOptions`](/pixi-vn-live2d/core/interfaces/MotionManagerOptions)

Initialization options for the manager.

#### Returns [#returns-12]

`void`

***

### initializeAudio() [#initializeaudio]

\> `protected` **initializeAudio**(`audio`, `volume`): `void`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3490

Initializes audio playback and sets up audio analysis for lipsync.

#### Parameters [#parameters-10]

##### audio [#audio]

`Sound`

The Sound to initialize.

##### volume [#volume]

`number`

The playback volume (0-1).

#### Returns [#returns-13]

`void`

***

### isFinished() [#isfinished]

\> `abstract` **isFinished**(): `boolean`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3570

Checks if the motion playback has finished.

#### Returns [#returns-14]

`boolean`

***

### listenerCount() [#listenercount]

\> **listenerCount**(`event`): `number`

Defined in: node_modules/eventemitter3/index.d.ts:27

Return the number of listeners listening to a given event.

#### Parameters [#parameters-11]

##### event [#event-2]

`string` | `symbol`

#### Returns [#returns-15]

`number`

#### Inherited from [#inherited-from-4]

`EventEmitter.listenerCount`

***

### listeners() [#listeners]

\> **listeners**\<`T`>(`event`): (...`args`) => `void`\[]

Defined in: node_modules/eventemitter3/index.d.ts:20

Return the listeners registered for a given event.

#### Type Parameters [#type-parameters-3]

##### T [#t-2]

`T` *extends* `string` | `symbol`

#### Parameters [#parameters-12]

##### event [#event-3]

`T`

#### Returns [#returns-16]

(...`args`) => `void`\[]

#### Inherited from [#inherited-from-5]

`EventEmitter.listeners`

***

### loadMotion() [#loadmotion]

\> **loadMotion**(`group`, `index`): `Promise`\<`Motion` | `undefined`>

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3479

Loads a Motion in a motion group. Errors in this method will not be thrown,
but be emitted with a "motionLoadError" event.

#### Parameters [#parameters-13]

##### group [#group-2]

`string`

The motion group.

##### index [#index-1]

`number`

Index in the motion group.

#### Returns [#returns-17]

`Promise`\<`Motion` | `undefined`>

Promise that resolves with the Motion, or with undefined if it can't be loaded.

#### Emits [#emits-2]

[MotionManagerEvents.motionLoaded](/pixi-vn-live2d/core/interfaces/MotionManagerEvents#motionloaded)

#### Emits [#emits-3]

[MotionManagerEvents.motionLoadError](/pixi-vn-live2d/core/interfaces/MotionManagerEvents#motionloaderror)

***

### motionLastFrame() [#motionlastframe]

\> `abstract` **motionLastFrame**(`group`, `index`, `expression`): `Promise`\<`boolean`>

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3646

Play the last frame of the given motion, optionally applying an expression.

#### Parameters [#parameters-14]

##### group [#group-3]

`string`

Motion group.

##### index [#index-2]

`number`

Motion index.

##### expression [#expression-1]

Expression to apply (optional).

###### expression? [#expression-2]

`string` | `number`

#### Returns [#returns-18]

`Promise`\<`boolean`>

Promise resolving to true if successful.

***

### mouthSync() [#mouthsync]

\> **mouthSync**(): `number`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3560

Move the mouth for lipsync.

#### Returns [#returns-19]

`number`

The current lipsync value.

***

### off() [#off]

\> **off**\<`T`>(`event`, `fn?`, `context?`, `once?`): `this`

Defined in: node_modules/eventemitter3/index.d.ts:69

#### Type Parameters [#type-parameters-4]

##### T [#t-3]

`T` *extends* `string` | `symbol`

#### Parameters [#parameters-15]

##### event [#event-4]

`T`

##### fn? [#fn-1]

(...`args`) => `void`

##### context? [#context-1]

`any`

##### once? [#once]

`boolean`

#### Returns [#returns-20]

`this`

#### Inherited from [#inherited-from-6]

`EventEmitter.off`

***

### on() [#on]

\> **on**\<`T`>(`event`, `fn`, `context?`): `this`

Defined in: node_modules/eventemitter3/index.d.ts:40

Add a listener for a given event.

#### Type Parameters [#type-parameters-5]

##### T [#t-4]

`T` *extends* `string` | `symbol`

#### Parameters [#parameters-16]

##### event [#event-5]

`T`

##### fn [#fn-2]

(...`args`) => `void`

##### context? [#context-2]

`any`

#### Returns [#returns-21]

`this`

#### Inherited from [#inherited-from-7]

`EventEmitter.on`

***

### once() [#once-1]

\> **once**\<`T`>(`event`, `fn`, `context?`): `this`

Defined in: node_modules/eventemitter3/index.d.ts:54

Add a one-time listener for a given event.

#### Type Parameters [#type-parameters-6]

##### T [#t-5]

`T` *extends* `string` | `symbol`

#### Parameters [#parameters-17]

##### event [#event-6]

`T`

##### fn [#fn-3]

(...`args`) => `void`

##### context? [#context-3]

`any`

#### Returns [#returns-22]

`this`

#### Inherited from [#inherited-from-8]

`EventEmitter.once`

***

### removeAllListeners() [#removealllisteners]

\> **removeAllListeners**(`event?`): `this`

Defined in: node_modules/eventemitter3/index.d.ts:79

Remove all listeners, or those of the specified event.

#### Parameters [#parameters-18]

##### event? [#event-7]

`string` | `symbol`

#### Returns [#returns-23]

`this`

#### Inherited from [#inherited-from-9]

`EventEmitter.removeAllListeners`

***

### removeListener() [#removelistener]

\> **removeListener**\<`T`>(`event`, `fn?`, `context?`, `once?`): `this`

Defined in: node_modules/eventemitter3/index.d.ts:63

Remove the listeners of a given event.

#### Type Parameters [#type-parameters-7]

##### T [#t-6]

`T` *extends* `string` | `symbol`

#### Parameters [#parameters-19]

##### event [#event-8]

`T`

##### fn? [#fn-4]

(...`args`) => `void`

##### context? [#context-4]

`any`

##### once? [#once-2]

`boolean`

#### Returns [#returns-24]

`this`

#### Inherited from [#inherited-from-10]

`EventEmitter.removeListener`

***

### setupMotions() [#setupmotions]

\> `protected` **setupMotions**(`options?`): `void`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3469

Sets up motions from the definitions, and preloads them according to the preload strategy.

#### Parameters [#parameters-20]

##### options? [#options-1]

[`MotionManagerOptions`](/pixi-vn-live2d/core/interfaces/MotionManagerOptions)

Options controlling which motions to preload.

#### Returns [#returns-25]

`void`

***

### speak() [#speak]

\> **speak**(`sound`, `volume?`): `Promise`\<`boolean`>

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3502

Only play sound with lip sync.

#### Parameters [#parameters-21]

##### sound [#sound]

`string`

The audio url or base64 content.

##### volume? [#volume-1]

Volume of the sound (0-1).

###### expression? [#expression-3]

`string` | `number`

###### onError? [#onerror]

(`e`) => `void`

###### onFinish? [#onfinish-1]

() => `void`

###### resetExpression? [#resetexpression]

`boolean`

###### volume? [#volume-2]

`number`

#### Returns [#returns-26]

`Promise`\<`boolean`>

Promise that resolves with true if the sound is playing, false otherwise.

***

### startMotion() [#startmotion]

\> **startMotion**(`group`, `index`, `priority?`, `sound?`): `Promise`\<`boolean`>

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3525

Starts a motion with the given priority.

#### Parameters [#parameters-22]

##### group [#group-4]

`string`

The motion group.

##### index [#index-3]

`number`

Index in the motion group.

##### priority? [#priority]

[`MotionPriority`](/pixi-vn-live2d/core/enumerations/MotionPriority)

The priority to be applied. Default: NORMAL (2).

##### sound? [#sound-1]

[`MotionStartOptions`](/pixi-vn-live2d/core/interfaces/MotionStartOptions)

The audio url or base64 content.

#### Returns [#returns-27]

`Promise`\<`boolean`>

Promise that resolves with true if the motion is successfully started, false otherwise.

***

### startRandomMotion() [#startrandommotion]

\> **startRandomMotion**(`group`, `priority?`, `sound?`): `Promise`\<`boolean`>

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3540

Starts a random Motion as given priority.

#### Parameters [#parameters-23]

##### group [#group-5]

`string`

The motion group.

##### priority? [#priority-1]

[`MotionPriority`](/pixi-vn-live2d/core/enumerations/MotionPriority)

The priority to be applied. Default: IDLE (1).

##### sound? [#sound-2]

[`MotionStartRandomOptions`](/pixi-vn-live2d/core/type-aliases/MotionStartRandomOptions)

The audio url or base64 content.

#### Returns [#returns-28]

`Promise`\<`boolean`>

Promise that resolves with true if the motion is successfully started, false otherwise.

***

### stopAllMotions() [#stopallmotions]

\> **stopAllMotions**(): `void`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3548

Stops all playing motions as well as the sound.

#### Returns [#returns-29]

`void`

***

### stopSpeaking() [#stopspeaking]

\> **stopSpeaking**(): `void`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3544

Stops current audio playback and lipsync.

#### Returns [#returns-30]

`void`

***

### update() [#update]

\> **update**(`model`, `now`): `boolean`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3555

Updates parameters of the core model.

#### Parameters [#parameters-24]

##### model [#model]

`object`

The core model.

##### now [#now]

`number`

Current time in milliseconds.

#### Returns [#returns-31]

`boolean`

True if the parameters have been actually updated.

***

### updateParameters() [#updateparameters]

\> `abstract` `protected` **updateParameters**(`model`, `now`): `boolean`

Defined in: node_modules/untitled-pixi-live2d-engine/types/index.d.ts:3628

Updates parameters of the core model.

#### Parameters [#parameters-25]

##### model [#model-1]

`object`

The core model.

##### now [#now-1]

`number`

Current time in milliseconds.

#### Returns [#returns-32]

`boolean`

True if the parameters have been actually updated.
