一、wordpress sakura 美化 添加看版娘

一、wordpress sakura 美化 添加看版娘

(一)、简单使用

1、资源下载

live2d-widget:https://github.com/stevenjoezhang/live2d-widget
live2d_api:https://github.com/fghrsh/live2d_api

live2d

2、资源上传

上传资源到主题Sakura 根目录下。
在这里插入图片描述

3、引入live2d

编辑Sakura主题中的文件header.php,引入live2d
引入live2d

注:

  • <?php echo get_template_directory_uri(); ?>:表示获取live2d在服务器上的位置。如果live2d是放在服务器根目录,可以不用添加。
  • live2d也可以放在在线地址(而不是服务器上)之后添加引用即可

(二)目录说明

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

(三)、首页隐藏

首页全屏时隐藏看版娘,引入js

// live2d-show.js
 let observer = new IntersectionObserver((entries) => {
        // 可见性修改
        let displayStr = entries[0].intersectionRatio > 0.8 ? "none" : "block";
        let live2d_dom = document.getElementById("waifu");
        if(live2d_dom){
            live2d_dom.style.display = displayStr;
        }
    }, { threshold: [0, 0.1, 0.8, 1]})

let dom = document.getElementById("main-container");
if(dom.firstElementChild){
    observer.observe(dom.firstElementChild)
}

// footer.php
...
<?php endif; ?>
</body>
<!-- 看板娘首页隐藏 -->
<script src="<?php echo get_template_directory_uri(); ?>/js/live2d-show.js"></script>
</html>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值