Giter Site home page Giter Site logo

hexo-helper-live2d's Introduction

The project is not actively maintained. Please try similar projects stevenjoezhang/live2d-widget

hexo-helper-live2d

npm package dependencies devDependencies

downloads-total downloads-month

stars forks issues

commitizen PRs license

Backers on Open Collective Sponsors on Open Collective

Read this in other languages: English, 简体中文.


Add the Sseexxyyy live2d to your hexo!

Demo: https://l2dwidget.js.org/dev.html

Author's original Blog: https://huaji8.top/post/live2d-plugin-2.0/

Installation

Hexo

Install module:

npm install --save hexo-helper-live2d

try yarn add hexo-helper-live2d for better installation experience. Yarn

Still using legacy version?
  • If you want to use new injector, which will inject to all pages:

Please delete {{ live2d() }} or <%- live2d() %> before </body> in layout/layout.ejs or layout/_layout.swig.

  • If you want to use the old replace mode, which only replace live2d tag:

Keep {{ live2d() }} or <%- live2d() %>, and turn the tagMode config to true.

We recommend you to use npm install --save [email protected] to force install the latest version.

Tag mode

Please insert {{ live2d() }}(swig) or <%- live2d() %>(ejs) before </body> in whichever pages you want to insert. And turn tagMode config to true, and then live2dwidget will only be on those who have live2d tag.

Others, for jekyll, wordpress, etc

See live2d-widget.js WIP.

Config

Add configuration in hexo's _config.yml file or theme's _config.yml.

An Example:

live2d:
  enable: true
  scriptFrom: local
  pluginRootPath: live2dw/
  pluginJsPath: lib/
  pluginModelPath: assets/
  tagMode: false
  log: false
  model:
    use: live2d-widget-model-wanko
  display:
    position: right
    width: 150
    height: 300
  mobile:
    show: true
  react:
    opacity: 0.7

Detail settings

Settings is divided into helper-specific ones and general ones, You can merge these two into your _config.yml file.

Helper-specific

# Live2D
## https://github.com/EYHN/hexo-helper-live2d
live2d:
  enable: true
  # enable: false
  pluginRootPath: live2dw/ # Root path of plugin to be on the site (Relative)
  pluginJsPath: lib/ # JavaScript path related to plugin's root (Relative)
  pluginModelPath: assets/ # Relative model path related to plugin's root (Relative)
  scriptFrom: local # Default
  # scriptFrom: jsdelivr # jsdelivr CDN
  # scriptFrom: unpkg # unpkg CDN
  # scriptFrom: https://cdn.jsdelivr.net/npm/[email protected]/lib/L2Dwidget.min.js # Your custom url
  tagMode: false # Whether only to replace live2d tag instead of inject to all pages
  log: false # Whether to show logs in console
  model:
    use: live2d-widget-model-wanko # npm-module package name
    # use: wanko # folder name in (hexo base dir)/live2d_models/
    # use: ./wives/wanko # folder path relative to hexo base dir
    # use: https://cdn.jsdelivr.net/npm/[email protected]/assets/wanko.model.json # Your custom url

To see Chinese explainations, please have a look at Chinese document.

General Settings

Recentlly may changes quickly, but don't worry, it won't make huge changes.

See live2d-widget.js API

An example:

# Live2D
## https://github.com/xiazeyu/live2d-widget.js
## https://l2dwidget.js.org/docs/class/src/index.js~L2Dwidget.html#instance-method-init
live2d:
  model:
    scale: 1
    hHeadPos: 0.5
    vHeadPos: 0.618
  display:
    superSample: 2
    width: 150
    height: 300
    position: right
    hOffset: 0
    vOffset: -20
  mobile:
    show: true
    scale: 0.5
  react:
    opacityDefault: 0.7
    opacityOnHover: 0.2

Models

There are many ways to use different models:

a. live2d_models's subfolder name

  1. Create a live2d_models folder at your blog's root directory.

  2. Create a folder by the name of your model.

  3. Copy your model to this folder.

  4. Type the folder name into model.use in _config.yml.

An Example:

Your model is named mymiku.

Then, create a folder at / (Which should exists _config.yml, sources, themes ) named mymiku.

Copy your model to /live2d_models/mymiku/.

Up to now, there should be an .model.json file (for example, mymiku.model.json)

in the directory of /live2d_models/mymiku/.

Type mymiku into model.use in _config.yml.

b. custom path relative to hexo base dir

You can just type your model folder's path which is relative to hexo base dir.

An example: ./wives/wanko

c. npm module's name

use exist ones

We alreday have tons of models, check this out

Click me if you are lazy
  • live2d-widget-model-chitose
  • live2d-widget-model-epsilon2_1
  • live2d-widget-model-gf
  • live2d-widget-model-haru/01 (use npm install --save live2d-widget-model-haru)
  • live2d-widget-model-haru/02 (use npm install --save live2d-widget-model-haru)
  • live2d-widget-model-haruto
  • live2d-widget-model-hibiki
  • live2d-widget-model-hijiki
  • live2d-widget-model-izumi
  • live2d-widget-model-koharu
  • live2d-widget-model-miku
  • live2d-widget-model-ni-j
  • live2d-widget-model-nico
  • live2d-widget-model-nietzsche
  • live2d-widget-model-nipsilon
  • live2d-widget-model-nito
  • live2d-widget-model-shizuku
  • live2d-widget-model-tororo
  • live2d-widget-model-tsumiki
  • live2d-widget-model-unitychan
  • live2d-widget-model-wanko
  • live2d-widget-model-z16

You can use npm install {your model's package name} to install,

and type it into model.use in _config.yml to use it.

make your own ones

  • Create an folder, use your node environment run npm init, we recommend you to name it like

live2d-widget-model-xxx.

  • Create an assets folder in the folder you just created, copy your model files into it.

Here's an example:

live2d-widget-model-wanko

  • Use npm publish to publish it.

  • Then use npm install --save live2d-widget-model-xxx,

and you can just type your package name(live2d-widget-model-wanko) into model.use

d. Your own CDN

If you are disappointed without CDN, you can just type your own .model.json url into model.use.


Enjoy!:beer:

Cheer for the 3.0 version and the new year!~

This is my first hexo plugin, star ⭐ and watch 👓, pull request is also welcomed.

Screenshots

TBD.

Contribute

Please pay enough attention to this document if you want to commit your changes or submit issues

This may help you a lot. All kinds of contributions are welcome.

CONTRIBUTING

Releated projects

Contributors

contributors

About me

author author QQ author email

collaborator0 collaborator0 QQ collaborator0 email

Imported

current-device


Open sourced under the GPL v2.0 license.

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers! 🙏 [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

hexo-helper-live2d's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hexo-helper-live2d's Issues

Chrome浏览器问题

不知道什么问题,我的chrome浏览器显示不出来,safari浏览器正常显示,这是那里没设置好么?

Hexo-fs版本不正确

该项目正在使用的是过期的hexo-fs 0.1.6
使用他会导致疯狂报错(node:13872) [DEP0061] DeprecationWarning: fs.SyncWriteStream is deprecated.
详细见
一个类似的issue
基本意思是fs.SyncWriteStream已经过期了,路过您的项目不使用,可以更新package.json中的hexo-fs到0.2.1版本

记得顺便更新一下npm哦

feat: online code generator

  • Using js and html to write it
  • Then put it onto Webbranch
  • 将name修改为多行下拉列表等
  • 使用路由(react)制作在线demo
  • dev.html加入一键召唤功能,直接调用insert.tmpl.html中的js

feat: add support for idle and mtn

提取到的一些模型含有久置动作,想把这些动作利用起来。
例如鼠标停留或移出浏览器窗口指定时间后触发

另外现在未对鼠标点击做处理吗?我看 main.js 里未处理 mousedownmouseup 事件

@EYHN @xiazeyu

文档补全

  • Code of conduct
  • Contributing
  • Issue or pull request template

we need jekyll-live2d

二次元 二次元 二次元

This feature is under unstable development, and we recommend you to subscribe this issue for the latest changes.
由于相关功能仍在开发中,我们建议您subscribe此issue来获取最新的变动。

feat: new ways of cJs building using webpack

头部转动不是很流畅

鼠标在一段范围头部不会转动,超出这个范围又会突然转动(鼠标离人物远一点然后鼠标上下动就很明显

会显得有点奇怪🙈

添加到主题的代码不对

文件是 /layout/_layout.swig
修改的代码:

<script type="text/javascript" src="/live2d/script"></script><script type="text/javascript">live2dStart("live2dcanvas","/live2d/z16/z16.model.json");</script>
<style>
.live2d{
position: fixed;
bottom: -30px;
right: 0px;
z-index: 999;
width: 150px;
height: 300px;
pointer-events: none
}
</style>

安装不了

Expected behavior (预期行为)

终端输入如下指令安装

npm install -save hexo-helper-live2d

Actual behavior (实际行为)

无法安装,报错

npm ERR! code EINTEGRITY
npm ERR! sha1-mYXGacUA8slGqQTvc3ir3dGgRMI= integrity checksum failed when using sha1: wanted sha1-mYXGacUA8slGqQTvc3ir3dGgRMI= but got sha1-rkEhFDik55a7FnyVkLLjyZZQIIQ=. (17877997 bytes)

重现方式

  • 1.打开至Blog根目录
  • 2.npm install -save hexo-helper-live2d

关于首页的一个问题

博客主页一直有一个错误是关于live2d的index里的,不知道是不是启用了HTTPS的原因。
Uploading Screenshot from 2017-09-30 01-38-30.png…

Get https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif?l=https://newdee.cf/ net::ERR_BLOCKED_BY_CLIENT

bug: poor motion reaction

Expected behavior 预期行为

拿shizuku 为例声音包里有15个文件,分为5个场景下的声音,但是无论我怎么点,都只有两种声音...特别是点击头部区域的时候,没有声音

Actual behavior 实际行为

只有两种声音

Steps to reproduce the behavior 复现步骤

点击!点击!点击!

Change the [ ] into [x] to show your acceptance.
[ ] 变为 [x] 来表示你接受了这些问题。

@EYHN @xiazeyu

模型位置问题

模型修改什么参数可以放在左侧呢?因为只看到了bottom参数,是不是只能改变离底部距离?

feat: message system

好像没实现对话互动的功能,还是我操作不对?说明文档一句话概况了,~

修改模型没有效果

我在代码里面的配置项选择了miku,可是在测试的时候下面的那个模型还是默认的那个,请问我该如何修改呢?谢谢。

新版本的问题

之前在本地解决了 #26 的问题,后来更新之后又出现了Uncaught TypeError:
image
然后看了下,貌似还是一样的解决方式,,,因为好像没变。。

device.js完善使用方式

  • npm install current-device
  • use lib/index.js
  • And then grab it off the global like so:
  • const device = device.default
  • 增加可选的CDN。本地/官方/自定
  • 完善许可

怎么修改脚本

不知道怎么修改脚本, 自己做了一些尝试:
修改:
\blog\themes\next\node_modules\hexo-helper-live2d\index.js

修改了71行的"right"
修改了72行的"z-index"

修改为:

 hexo.extend.helper.register('live2d', function (config) {
  var config = Object.assign(
    {
      model:"z16",
      width: 150,
      height: 300,
      className: "live2d",
      id: "live2dcanvas",
      bottom: -20
    },
    config, 
    hexo.config.live2d
  );
  return `
    <script type="text/javascript" src="/live2d/script.js"></script>
    <canvas id="${config.id}" width="${config.width}" height="${config.height}" class="${config.className}"></canvas>
    <style>
      #${config.id} {
        position: fixed;
        right: 10px;
        z-index: 9999;
        pointer-events: none;
        bottom: ${config.bottom}px;
      }
    </style>
    <script>loadlive2d(${JSON.stringify(config.id)} ,${JSON.stringify(url.resolve("/live2d/assets/",models[config.model]))})</script>
  `
});

但是在渲染的时候, 没有变化, 这是为什么呢?

3.0 developing log

  • 用js动态创造canvas
  • 内联style
  • 把参数都加到loadlive2d()的参数里
  • 把loadScript合并到device.min.js里
  • 简化代码
  • 修改cJs代码为单model
  • 分组settings
  • 最终把载入代码简化到一行
  • 能用js自动生成
  • 挂githubraw
  • 做一个通用代码(直接贴在wordpress或者什么奇怪的网页上就能直接用的那种)
  • webpack能不能用类似ejs,swig的模板功能,在相应位置添加js的hash?能否压缩html和其中的js?
  • 提醒用户升级的时候删除模板中的旧代码,更改_config.yml什么的?我想到可以把helper.generator()中的return替换成console.warn之类的。
  • 直接引入webpack编译完成的代码和js在线生成器
  • Webbrach
  • 调整 cJs function 顺序

http://www.jb51.net/article/78597.htm
http://blog.csdn.net/m0_37886429/article/details/69226386

3.0 Small To-do Tips

function loadlive2d(id,modelurl,headPos) {
    head_pos = typeof headPos === 'undefined' ? 0.5 : headPos;
    initL2dCanvas(id);
    init(modelurl);
}

添加代码到主题

请教一下作者,

<%- live2d() %>
这段代码要放在主题的哪个文件里面

25bad6c以来发现的问题和改进

1,Unable to get property 'getDrawDataIndex' of undefined or null reference
at Live2DFramework.js (274,1)

#26 有关Orz
Fixed, WFT, Tested.

3,移动设备上的WebGL模糊 Fixed, brought bug7

6.opacity

2,Blinking issue.即有的时候canvas会闪烁黑色

7,头部位置问题

4,[Improves]移动设备加入重力感应

5,[Improves]每日一句

feat: custom HIT_AREA support

部分模型不带 HIT_AREA,是否可增加相应处理,使得通过model.json中提供的参数手动定义 HIT_AREA。
定义方式可使用矩形区域左上角和右下角两点坐标。
坐标可通过启用DEBUG_MOUSE_LOG得到,因此与此同时应能方便的修改LAppDefine

@EYHN @xiazeyu

Warning after install this script

After install this script, it always comes out like this:

(node:9217) [DEP0061] DeprecationWarning: fs.SyncWriteStream is deprecated.

关于加载速度的优化

这个宠物挺不错的,但是放在博客后感觉加载明显满了很多,我看了一下,时间有时候会很长,请问有没有什么可以加速的方案?
screenshot from 2017-09-27 20-37-09

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.