Git Product home page Git Product logo

live2d_api's Introduction

Live2D API

Live2D 看板娘插件 (https://www.fghrsh.net/post/123.html) 上使用的后端 API

特性

  • 原生 PHP 开发,无需伪静态,开箱即用
  • 支持 模型、皮肤 的 顺序切换 和 随机切换
  • 支持 单模型 单皮肤 切换、多组皮肤 递归穷举
  • 支持 同分组 多个模型 或 多个路径 的 加载切换

使用

环境要求

  • PHP 版本 >= 5.2
  • 依赖 PHP 扩展:json

目录结构

│  model_list.json              // 模型列表
│
├─model                         // 模型路径
│  └─GroupName                  // 模组分组
│      └─ModelName              // 模型名称
│
├─add                           // 更新皮肤列表
├─get                           // 获取模型配置
├─rand                          // 随机切换模型
├─rand_textures                 // 随机切换皮肤
├─switch                        // 顺序切换模型
├─switch_textures               // 顺序切换皮肤
└─tools
        modelList.php           // 列出模型列表
        modelTextures.php       // 列出皮肤列表
        name-to-lower.php       // 文件名格式化

添加模型

  • 单模型 单皮肤 切换
    • 单次加载只输出一个皮肤
    • 皮肤放在 textures 文件夹,自动识别
│  index.json
│  model.moc
│  textures.cache       // 皮肤列表缓存,自动生成
│
├─motions
│      idle_01.mtn
│      idle_02.mtn
│      idle_03.mtn
│
└─textures
        default-costume.png
        school-costume.png
        winter-costume.png
  • 单模型 多组皮肤 递归穷举
    • 多组皮肤 组合模型、穷举组合
    • 皮肤文件夹按 texture_XX 命名
    • 添加 textures_order.json 列出组合
│  index.json
│  model.moc
│  textures.cache
│  textures_order.json
│
├─motions
│      idle_01.mtn
│      idle_02.mtn
│      idle_03.mtn
│
├─texture_00
│      00.png
│
├─texture_01
│      00.png
│      01.png
│      02.png
│
├─texture_02
│      00.png
│      01.png
│      02.png
│
└─texture_03
       00.png
       01.png

textures_order.json

[
    ["texture_00"],
    ["texture_01","texture_02"],
    ["texture_03"]
]

textures.cache

[
    ["texture_00/00.png","texture_01/00.png","texture_02/00.png","texture_03/00.png"],
    ["texture_00/00.png","texture_01/00.png","texture_02/00.png","texture_03/01.png"],
    ["texture_00/00.png","texture_01/01.png","texture_02/01.png","texture_03/00.png"],
    ["texture_00/00.png","texture_01/01.png","texture_02/01.png","texture_03/01.png"],
    ["texture_00/00.png","texture_01/02.png","texture_02/02.png","texture_03/00.png"],
    ["texture_00/00.png","texture_01/02.png","texture_02/02.png","texture_03/01.png"]
]
  • 同分组 多个模型 或 多个路径 切换
    • 修改 model_list.json 添加多个模型
│
├─model
│  ├─Group1
│  │  ├─Model1
│  │  │      index.json
│  │  │
│  │  └─Model2
│  │          index.json
│  │
│  ├─Group2
│  │  └─Model1
│  │          index.json
│  │
│  └─GroupName
│     └─ModelName
│          │  index.json
│          │  model.moc
│          │
│          ├─motions
│          └─textures
│

model_list.json

{
    "models": [
        "GroupName/ModelName",
        [
            "Group1/Model1",
            "Group1/Model2",
            "Group2/Model1"
        ]
    ],
    "messages": [
        "Example 1",
        "Example 2"
    ]
}

接口用法

  • /add/ - 检测 新增皮肤 并更新 缓存列表
  • /get/?id=1-23 获取 分组 1 的 第 23 号 皮肤
  • /rand/?id=1 根据 上一分组 随机切换
  • /switch/?id=1 根据 上一分组 顺序切换
  • /rand_textures/?id=1-23 根据 上一皮肤 随机切换 同分组其他皮肤
  • /switch_textures/?id=1-23 根据 上一皮肤 顺序切换 同分组其他皮肤

版权声明

(>▽<) 都看到这了,点个 Star 吧 ~

API 内所有模型 版权均属于原作者,仅供研究学习,不得用于商业用途

MIT © FGHRSH

live2d_api's People

Contributors

fghrsh avatar sinonjzh avatar

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

live2d_api's Issues

有没有出现过api中的model文件造成git clone失败问题,如何解决

kuukie-kq/HodgePodge@29e8e60

自己的项目中引用了model资源,原本没出现这种问题,近期发现整个项目无法clone

然后经过排除发现原因是model中的文件造成clone失败,想问一下有没有出现这种情况,以及如何彻底解决clone问题

目前项目可以git clone --depth=1,但以前提交的记录无法拉取下来(既git fetch --unshallow依然报错)

报错信息有两种:
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
error: 2717 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output
以及
error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 0
error: 5711 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output

还有就是想知道为什么这个文件会造成这个报错

Update .png images to .webp image

Hello @fghrsh,
I wanted to update the textures .png images to .webp image. Reason for that :

  1. WebP offers 26% smaller file sizes than PNG, while still providing transparency and the same quality.
  2. WebP loads faster (due to file size) than PNG images.

and it is also recommended to use .webp images instead of png images.

自建api请求报错(跨域问题)

博客部署在github page和coding page。
在三个蛋上把api整个文件放进去后测试了一下1-46
https://my-live2d-api.000webhostapp.com/live2d_api/get/?id=1-46
在浏览器能正常获取json,但是修改live2d里面的api接口路径的时候报错
Access to XMLHttpRequest at 'https://my-live2d-api.000webhostapp.com/live2d_api/get/?id=1-46' from origin 'https://8chen.club' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
好像是需要设置Access-Control-Allow-Origin,但并不是很懂php。。。
现在改回了 //live2d.fghrsh.net/api/ 应急

如何批量添加模型?

你好,目前github上的live2d人物模型分享和此项目的api目录形式有所不同,请问能否实现人物模型的批量导入?

如何加载模型后对模型进行平移

你好,

由于自己的模型头发太高,点头动作会导致呆毛有一部分被canvas截断,请问如何设置加载模型时或显示模型时,将模型向下偏移一段距离?谢谢你!

live2d 切换人物模型资源加载问题

问题:waifu-tips.js 进行资源加载时error !
如图所示:
live2d source Loading problem

描述:live2d source Loading problem
加载模型:Live2D 模型 6-0 加载完成后出现错误
html page error msg :
Package size exceeded the configured limit of 50 MB. Try https://github.com/fghrsh/live2d_api/tree/1.0.0/model/HyperdimensionNeptunia/nepnep/general/pose.json instead.

已尝试解决方案:
切换文件内部资源加载链接为本地:
42行 script.src = "https://cdn.jsdelivr.net/gh/GalaxyMimi/CDN/asteroids.js";
54行 open("https://github.com/stevenjoezhang/live2d-widget");

仍未解决;分析原因可能不是因为这两份资源导致。
如大佬有时间请看一下是否能处理,不胜感激。

说明:通过demo进行测试人物切换一样的问题。
我是按照顺序切换模型的,当切换至模型6时就出现资源403问题。
下载demo在本地测一样的结果,demo1;
我这边环境为 macOS Mojave 10.14.3 目前 测试了两款浏览器:google、Microsoft Edge 均浮现,我觉得可能是因为加载了人物说话声音的资源导致的。因为不发声的人物没有问题

api请求报错了

2020/4/29 晚上7点,请求api接口的时候报错了,
[Error] Failed to load resource: 此服务器的证书无效。您可能正在连接一个伪装成“live2d.fghrsh.net”的服务器,这会威胁到您的机密信息的安全。 (get, line 0)

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.