当前位置: 首页 > news >正文

【live2d】看板娘人物模型使用方法

 文件地址:stevenjoezhang/live2d-widget CDN by jsDelivr - A free, fast, and reliable Open Source CDN

实现效果

使用方法:

新建utils文件,创建live2d.js

// live2d_path 参数建议使用绝对路径
const live2d_path = "https://cdn.jsdelivr.net/gh/stevenjoezhang/live2d-widget@latest/";
//const live2d_path = "/live2d-widget/";// 封装异步加载资源的方法
function loadExternalResource(url, type) {return new Promise((resolve, reject) => {let tag;if (type === "css") {tag = document.createElement("link");tag.rel = "stylesheet";tag.href = url;}else if (type === "js") {tag = document.createElement("script");tag.src = url;}if (tag) {tag.onload = () => resolve(url);tag.onerror = () => reject(url);document.head.appendChild(tag);}});
}// 加载 waifu.css live2d.min.js waifu-tips.js
if (screen.width >= 768) {Promise.all([loadExternalResource(live2d_path + "waifu.css", "css"),loadExternalResource(live2d_path + "live2d.min.js", "js"),loadExternalResource(live2d_path + "waifu-tips.js", "js")]).then(() => {// 配置选项的具体用法见 README.mdinitWidget({waifuPath: live2d_path + "waifu-tips.json",//apiPath: "https://live2d.fghrsh.net/api/",cdnPath: "https://cdn.jsdelivr.net/gh/fghrsh/live2d_api/",tools: ["hitokoto", "asteroids", "switch-model", "switch-texture", "photo", "info", "quit"]});});
}

main.js引入

import './utils/live2d'


http://www.mrgr.cn/news/49926.html

相关文章:

  • CASA(Carnegie-Ames-Stanford Approach) 模型原理及实践技术
  • 【Linux】解析信号的本质&相关函数及指令的介绍
  • 嵌入式归一板,传统归一板。你会如何选择?
  • 并行 parallel broadcast partition pruning 分区裁剪 optimizer_dynamic_sampling=7
  • 解决java.lang.NoSuchMethodError: kotlin.collections.ArraysKt.copyInto([B[BIII)[B
  • 搞定SpringCloud面试(含答案和思维导图)
  • 【华为】配置BGP协议
  • 电脑c盘太满了,如何清理?
  • 2023年中国环境统计年鉴(EXCEL)
  • Flac转成Mp3格式,小白也能学会的三种技巧
  • golang 报错:invalid character ‘‘ looking for beginning of object key string
  • 自定义HTTPS证书用于内网环境
  • U盘启动后报错 “ Verifying shim SBAT data failed: Security Policy Violation Something
  • 无线工作流程
  • 人工智能 | openai chatgpt 大语言模型
  • Selenium 测试 Electron 应用
  • 最小生成树专题
  • 代码审计笔记-PHP
  • k8s Node节点维护
  • 【算法】贪心算法