live2d-widget icon indicating copy to clipboard operation
live2d-widget copied to clipboard

默认modelId为1会导致在模型只有一个的情况下无法正确加载模型

Open wuuconix opened this issue 2 years ago • 1 comments
trafficstars

问题代码: https://github.com/stevenjoezhang/live2d-widget/blob/ae27493c29391e0cf2e9c08d27ab9d466f0a9c93/src/index.js#L134 本项目默认加载modelId为1的模型。 当使用cdn方式加载模型时,modelId将作为数组下标。 https://github.com/stevenjoezhang/live2d-widget/blob/ae27493c29391e0cf2e9c08d27ab9d466f0a9c93/src/model.js#L32 而当cdn中只有一个模型时,this.modelList.models 这个数组将只存在一个元素,即下标为0的那个元素 而默认modelId默认为1,故this.modelList.models[1]将返回undefined。 这最终导致target这个原本应该是模型名称的变量成为undefined。

image

复现页面: https://codepen.io/wuuconix/pen/RwYeKPm 将默认modelId设置为0后的效果: https://codepen.io/wuuconix/pen/abaRpEQ

wuuconix avatar Mar 21 '23 15:03 wuuconix

我目前的做法是修改 waifu-tips.js 中的这个函数,把它们的值都改成 0

image

然后模型就可以正常加载了(可能我选择的模型比 live2d_api 默认模型大,导致 <canvas /> 画不全)

Dragon1573 avatar May 25 '24 13:05 Dragon1573

谢谢反馈,已修复: https://github.com/stevenjoezhang/live2d-widget/commit/cc487faabd844c47920dce592f3044b6220518ec 后端API默认会给模型id增加1,导致API与CDN模型id不一致

stevenjoezhang avatar May 16 '25 19:05 stevenjoezhang