Home Reference Source
import {L2Dwidget} from 'live2d-widget/src/index.js'
public class | source

L2Dwidget

The main entry point, which is ... nothing

Method Summary

Public Methods
public

captureFrame(callback: Function): null

Capture current frame to png file captureFrame

public

download current frame L2Dwidget.captureFrame

public

init(userConfig: Object): null

The init function

Public Methods

public captureFrame(callback: Function): null source

Capture current frame to png file captureFrame

Params:

NameTypeAttributeDescription
callback Function

The callback function which will receive the current frame

Return:

null

public downloadFrame(): null source

download current frame L2Dwidget.captureFrame

Return:

null

public init(userConfig: Object): null source

The init function

Params:

NameTypeAttributeDescription
userConfig Object
  • optional

User's custom config 用户自定义设置

userConfig.model.jsonPath String
  • optional
  • default: ''

Path to Live2D model's main json eg. https://test.com/miku.model.json model主文件路径

userConfig.model.scale Number
  • optional
  • default: 1

Scale between the model and the canvas 模型与canvas的缩放

userConfig.model.hHeadPos Number
  • optional
  • default: 0.5

Horizontal position of model's head 模型头部横坐标

userConfig.model.vHeadPos Number
  • optional
  • default: 0.618

Vertical position of model's head 模型头部纵坐标

userConfig.model.myDefine Array
  • optional
  • default: []

User's custom Defines which will override LDefine 自定义的LDefine

userConfig.display.superSample Number
  • optional
  • default: 2

rate for super sampling rate 超采样等级

userConfig.display.width Number
  • optional
  • default: 150

Width to the canvas which shows the model canvas的长度

userConfig.display.height Number
  • optional
  • default: 300

Height to the canvas which shows the model canvas的高度

userConfig.display.position String
  • optional
  • default: 'right'

Left of right side to show 显示位置:左或右

userConfig.display.hOffset Number
  • optional
  • default: 0

Horizontal offset of the canvas canvas水平偏移

userConfig.display.vOffset Number
  • optional
  • default: -20

Vertical offset of the canvas canvas垂直偏移

userConfig.mobile.show Boolean
  • optional
  • default: true

Whether to show on mobile device 是否在移动设备上显示

userConfig.mobile.scale Number
  • optional
  • default: 0.5

Scale on mobile device 移动设备上的缩放

userConfig.mobile.motion Boolean
  • optional
  • default: true

Whether to enable motion detection on mobile devices 移动设备是否开启重力感应

userConfig.name.canvas String
  • optional
  • default: 'live2dcanvas'

ID name of the canvas canvas元素的ID

userConfig.name.div String
  • optional
  • default: 'live2d-widget'

ID name of the div div元素的ID

userConfig.react.opacityDefault Number
  • optional
  • default: 0.7

Default opacity 默认透明度

userConfig.react.opacityOnHover Number
  • optional
  • default: 0.2

OnHover opacity 鼠标移上透明度

userConfig.react.myFunc Function
  • optional
  • default: func(e)

Custom event handler, won't override main handler, will reveice the event type. 自定义事件接收器

userConfig.dev.log Boolean
  • optional
  • default: false

Whether to show log 显示日志

userConfig.dev.border Boolean
  • optional
  • default: false

Whether to show border around the canvas 在canvas周围显示边界

userConfig.dev.mouseLog Boolean
  • optional
  • default: false

Whether to show mouse log (tons of log), only work when dev.log is enabled 显示鼠标移动

userConfig.dev.mouseFunc Function
  • optional
  • default: func(x, y, ix, iy)

Custom logger, only work when dev.log is enabled, will receive (x, y, ix, iy), which presents the actucally position and vitural position 自定义鼠标移动处理函数

Return:

null