LogoPixi’VN
coreClasses

Abstract Class: MotionManager<Motion, MotionSpec>

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

MotionManagerEvents

Extends

  • EventEmitter

Extended by

Type Parameters

Motion

Motion = unknown

MotionSpec

MotionSpec = unknown

Constructors

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

parent

InternalModel

The parent InternalModel.

Returns

MotionManager<Motion, MotionSpec>

Overrides

EventEmitter.constructor

Properties

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?

> 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?

> 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

> 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: boolean

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

Flags whether the instance has been destroyed.


expressionManager?

> abstract optional expressionManager?: 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

> 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: string


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: 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, 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: InternalModel

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

Reference to the parent InternalModel.


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

> readonly settings: ModelSettings

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

The ModelSettings reference.


state

> state: MotionState

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

Maintains the state of this MotionManager.


tag

> tag: string

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

Tag for logging.


prefixed

> static prefixed: string | boolean

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

Inherited from

EventEmitter.prefixed

Methods

_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

motion

Motion

The Motion to start.

onFinish?

(motion) => void

Optional callback when finished.

ignoreParamIds?

string[]

The ids to be ignored.

loop?

boolean

Whether the motion should loop.

Returns

number

An ID or token for the motion.


_stopAllMotions()

> abstract protected _stopAllMotions(): void

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

Stops all playing motions.

Returns

void


addListener()

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

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

Type Parameters

T

T extends string | symbol

Parameters

event

T

fn

(...args) => void

context?

any

Returns

this

Inherited from

EventEmitter.addListener


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

data

object | ArrayBuffer

Content of the motion file. The format must be consistent with MotionManager#motionDataType.

group

string

The motion group.

definition

MotionSpec

The motion definition.

Returns

Motion

The created Motion.


destroy()

> destroy(): void

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

Destroys the instance and releases all resources.

Returns

void

Emits

MotionManagerEvents.destroy


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

T

T extends string | symbol

Parameters

event

T

args

...any[]

Returns

boolean

Inherited from

EventEmitter.emit


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

(string | symbol)[]

Inherited from

EventEmitter.eventNames


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

group

string

The motion group.

index

number

The motion index.

expression?

string | number

Expression to apply (optional).

Returns

Promise<unknown>

The loaded motion, or null if not started.


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

definition

MotionSpec

Motion definition.

Returns

string

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


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

definition

MotionSpec

Motion definition.

Returns

string

The motion's name.


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

definition

MotionSpec

Motion definition.

Returns

string | undefined

The motion's sound file, or undefined.


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

options?

MotionManagerOptions

Initialization options for the manager.

Returns

void


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

audio

Sound

The Sound to initialize.

volume

number

The playback volume (0-1).

Returns

void


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

boolean


listenerCount()

> listenerCount(event): number

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

Return the number of listeners listening to a given event.

Parameters

event

string | symbol

Returns

number

Inherited from

EventEmitter.listenerCount


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

T

T extends string | symbol

Parameters

event

T

Returns

(...args) => void[]

Inherited from

EventEmitter.listeners


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

group

string

The motion group.

index

number

Index in the motion group.

Returns

Promise<Motion | undefined>

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

Emits

MotionManagerEvents.motionLoaded

Emits

MotionManagerEvents.motionLoadError


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

group

string

Motion group.

index

number

Motion index.

expression

Expression to apply (optional).

expression?

string | number

Returns

Promise<boolean>

Promise resolving to true if successful.


mouthSync()

> mouthSync(): number

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

Move the mouth for lipsync.

Returns

number

The current lipsync value.


off()

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

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

Type Parameters

T

T extends string | symbol

Parameters

event

T

fn?

(...args) => void

context?

any

once?

boolean

Returns

this

Inherited from

EventEmitter.off


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

T

T extends string | symbol

Parameters

event

T

fn

(...args) => void

context?

any

Returns

this

Inherited from

EventEmitter.on


once()

> 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

T

T extends string | symbol

Parameters

event

T

fn

(...args) => void

context?

any

Returns

this

Inherited from

EventEmitter.once


removeAllListeners()

> removeAllListeners(event?): this

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

Remove all listeners, or those of the specified event.

Parameters

event?

string | symbol

Returns

this

Inherited from

EventEmitter.removeAllListeners


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

T

T extends string | symbol

Parameters

event

T

fn?

(...args) => void

context?

any

once?

boolean

Returns

this

Inherited from

EventEmitter.removeListener


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

options?

MotionManagerOptions

Options controlling which motions to preload.

Returns

void


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

sound

string

The audio url or base64 content.

volume?

Volume of the sound (0-1).

expression?

string | number

onError?

(e) => void

onFinish?

() => void

resetExpression?

boolean

volume?

number

Returns

Promise<boolean>

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


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

group

string

The motion group.

index

number

Index in the motion group.

priority?

MotionPriority

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

sound?

MotionStartOptions

The audio url or base64 content.

Returns

Promise<boolean>

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


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

group

string

The motion group.

priority?

MotionPriority

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

sound?

MotionStartRandomOptions

The audio url or base64 content.

Returns

Promise<boolean>

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


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

void


stopSpeaking()

> stopSpeaking(): void

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

Stops current audio playback and lipsync.

Returns

void


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

model

object

The core model.

now

number

Current time in milliseconds.

Returns

boolean

True if the parameters have been actually updated.


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

model

object

The core model.

now

number

Current time in milliseconds.

Returns

boolean

True if the parameters have been actually updated.

On this page

EmitsExtendsExtended byType ParametersMotionMotionSpecConstructorsConstructorParametersparentReturnsOverridesPropertiescurrentAnalyzer?currentAudio?currentContext?definitionsdestroyedexpressionManager?groupsidlemotionDataTypemotionGroupsparentplayingsettingsstatetagprefixedInherited fromMethods_startMotion()ParametersmotiononFinish?ignoreParamIds?loop?Returns_stopAllMotions()ReturnsaddListener()Type ParametersTParameterseventfncontext?ReturnsInherited fromcreateMotion()ParametersdatagroupdefinitionReturnsdestroy()ReturnsEmitsemit()Type ParametersTParameterseventargsReturnsInherited fromeventNames()ReturnsInherited fromgetMotionAndApplyExpression()Parametersgroupindexexpression?ReturnsgetMotionFile()ParametersdefinitionReturnsgetMotionName()ParametersdefinitionReturnsgetSoundFile()ParametersdefinitionReturnsinit()Parametersoptions?ReturnsinitializeAudio()ParametersaudiovolumeReturnsisFinished()ReturnslistenerCount()ParameterseventReturnsInherited fromlisteners()Type ParametersTParameterseventReturnsInherited fromloadMotion()ParametersgroupindexReturnsEmitsEmitsmotionLastFrame()Parametersgroupindexexpressionexpression?ReturnsmouthSync()Returnsoff()Type ParametersTParameterseventfn?context?once?ReturnsInherited fromon()Type ParametersTParameterseventfncontext?ReturnsInherited fromonce()Type ParametersTParameterseventfncontext?ReturnsInherited fromremoveAllListeners()Parametersevent?ReturnsInherited fromremoveListener()Type ParametersTParameterseventfn?context?once?ReturnsInherited fromsetupMotions()Parametersoptions?Returnsspeak()Parameterssoundvolume?expression?onError?onFinish?resetExpression?volume?ReturnsstartMotion()Parametersgroupindexpriority?sound?ReturnsstartRandomMotion()Parametersgrouppriority?sound?ReturnsstopAllMotions()ReturnsstopSpeaking()Returnsupdate()ParametersmodelnowReturnsupdateParameters()ParametersmodelnowReturns