Handles all the network load tasks.

  • Model creation: requested by from.
  • Motion loading: implements the load method of MotionManager.
  • Expression loading: implements the load method of ExpressionManager.

Hierarchy

  • Live2DFactory

Constructors

Properties

createInternalModel: Middleware<Live2DFactoryContext> = createInternalModel
expressionTasksMap: WeakMap<ExpressionManager<any, any>, (undefined | Promise<any>)[]> = ...

Load tasks of each expression.

jsonToSettings: Middleware<Live2DFactoryContext> = jsonToSettings
live2DModelMiddlewares: Middleware<Live2DFactoryContext>[] = ...

Middlewares to run through when setting up a Live2DModel.

motionTasksMap: WeakMap<MotionManager<any, any>, Record<string, (undefined | Promise<any>)[]>> = ...

load tasks of each motion. The structure of each value in this map is the same as respective definitions.

runtimes: Live2DRuntime[] = []

All registered runtimes, sorted by versions in descending order.

setupEssentials: Middleware<Live2DFactoryContext> = setupEssentials
setupOptionals: Middleware<Live2DFactoryContext> = setupOptionals
urlToJSON: Middleware<Live2DFactoryContext> = urlToJSON
waitUntilReady: Middleware<Live2DFactoryContext> = waitUntilReady

Methods

  • Finds a runtime that matches given source.

    Returns

    The Live2DRuntime, or undefined if not found.

    Parameters

    • source: any

      Either a settings JSON object or a ModelSettings instance.

    Returns undefined | Live2DRuntime

  • Loads an Expression and registers the task to expressionTasksMap. The task will be automatically canceled when its owner - the ExpressionManager instance - has been destroyed.

    Returns

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

    Type Parameters

    • Expression

    • ExpressionSpec

    Parameters

    • expressionManager: ExpressionManager<Expression, ExpressionSpec>

      ExpressionManager that owns this Expression.

    • index: number

      Index of the Expression.

    Returns Promise<undefined | Expression>

  • Loads a Motion and registers the task to motionTasksMap. The task will be automatically canceled when its owner - the MotionManager instance - has been destroyed.

    Returns

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

    Type Parameters

    • Motion

    • MotionSpec

    Parameters

    • motionManager: MotionManager<Motion, MotionSpec>

      MotionManager that owns this Motion.

    • group: string

      The motion group.

    • index: number

      Index in the motion group.

    Returns Promise<undefined | Motion>

  • Sets up a Live2DModel, populating it with all defined resources.

    Returns

    Promise that resolves when all resources have been loaded, rejects when error occurs.

    Type Parameters

    Parameters

    • live2dModel: Live2DModel<IM>

      The Live2DModel instance.

    • source: string | object | IM["settings"]

      Can be one of: settings file URL, settings JSON object, ModelSettings instance.

    • Optional options: Live2DFactoryOptions

      Options for the process.

    Returns Promise<void>

Generated using TypeDoc