预览效果
这里有张图片:

0.用到的地址
(oh-my-live2d Github 地址)[https://github.com/oh-my-live2d/oh-my-live2d]
(oh-my-live2d 官网 地址)[https://oml2d.hacxy.cn/]
(live2d 模型下载 地址)[https://github.com/Eikanya/Live2d-model/tree/master]
(静态文件 Statically 地址)[https://statically.io/convert/]
(DownGit Github 文件夹下载器 地址)[https://minhaskamal.github.io/DownGit/#/home]
1.前言
需搭配 Hexo 使用,我目前使用的 hexo 版本为 7.3.0,教程很简单,可能需要自备魔法
2.安装
1. 安装 hexo-oh-my-live2d 插件
# 在 hexo 根目录 cmd 下输入如下命令 # 这里使用的是yarn命令,跟npm命令起到的效果是一样的 yarn add hexo-oh-my-live2d --save
|
2. 配置样式文件
OhMyLive2d: enable: true CDN: https://registry.npmmirror.com/oh-my-live2d/latest/files option: libraryUrls: complete: https://registry.npmmirror.com/oh-my-live2d/latest/files/lib/complete.js cubism2: https://registry.npmmirror.com/oh-my-live2d/latest/files/lib/cubism2.js cubism5: https://registry.npmmirror.com/oh-my-live2d/latest/files/lib/cubism5.js
mobileDisplay: false models: - path: "https://cdn.statically.io/gh/lingdubing-xo/lingdubing-xo-pic/main/%E5%8A%A0%E8%97%A4%E6%83%A0live2d/model/katou_01/katou_01.model.json" mobilePosition: [-10, 23] mobileScale: 0.1 mobileStageStyle: width: 180 height: 166 motionPreloadStrategy: IDLE position: [20, -150] scale: 0.15 stageStyle: width: 250 height: 250 - path: "https://cdn.statically.io/gh/lingdubing-xo/lingdubing-xo-pic/main/%E7%BA%B1%E9%9B%BElive2d/model/sagiri/sagiri.model.json" scale: 0.12 position: [30, 0] stageStyle: width: 250 mobileScale: 0.08 mobilePosition: [0, 0] mobileStageStyle: width: 180 parentElement: document.body primaryColor: "var(--btn-bg)" sayHello: false tips: style: width: 230 height: 120 left: calc(50% - 20px) top: -100px mobileStyle: width: 180 height: 80 left: calc(50% - 30px) top: -100px idleTips: interval: 15000 message: | function(){ return axios.get('https://v1.hitokoto.cn?c=i') .then(function (response) { return response.data.hitokoto ; }) .catch(function (error) { console.error(error); }); }
|
3.配置 github 资源床
1.进入到 github 官网上创建一个公开的项目
2.将 github 创建的项目拉到本地,在本地创建一个存储文件的文件夹
# github拉到本地 git pull 仓库位置
|
4.下载想要的模型
到(live2d 模型下载 地址)[https://github.com/Eikanya/Live2d-model/tree/master]下载想要的模型
要是压缩包直接下载到本地即可,有些模型是文件夹格式的直接下载不下来的话,可以使用(DownGit 工具)[https://minhaskamal.github.io/DownGit/#/home]将文件夹的地址复制上去然后下载,保存到刚才创建的那个存储文件的文件夹里
# 然后将下载的本地资源上传到github上 git add . git commit -m "你想要加的注释" git push
|
5.使用 Statically 做代理
*到(静态文件 Statically 地址)[https://statically.io/convert/]输入你 github 上模型的文件地址,一般为 model.json 结尾*
更改 config.yml 文件下的 path 路径即可修改模型
3.自定义模型设置(几个重要的参数)
- 如果一个模型有多个衣服的话。path 路径要设置为一个数据形式,如我 config.yml 设置的那样
- dockedPosition 是设置模型在网页左边或者右边
- 如果模型位置不恰当,请调整 position 属性,第一个为 x 轴,第二个为 y 轴,正数是向左向上,负数是向右向下
到这里教程就已圆满结束了,感谢你的浏览,thank you