Effect picture
Online demo: live2d
Source code: gitee
Instructions
1. Create a new folder in the root directory of your website and name it live2d
2. Put the assets-* folder corresponding to your favorite model and the two js files into your live2d folder
3. Rename the assets-* folder to assets
4. Add the following code to the html code of the page where you want the 2D model to appear (pay attention to changing the model name in the code):
<div>
<canvas id="live2dcanvas" width="150" height="300"></canvas>
</div>
<style>
#live2dcanvas {
position: fixed;
width: 150px;
height: 300px;
opacity: 0.7;
right: 0px;
z-index: 999;
pointer-events: none;
bottom: -20px;
}
</style>
<script type="text/javascript" src="/live2d/device.min.js"></script>
<script type="text/javascript">
const loadScript = function loadScript(c, b) {
var a = document.createElement("script");
a.type = "text/javascript";
"undefined" != typeof b && (a.readyState ? a.onreadystatechange = function () {
if ("loaded" == a.readyState || "complete" == a.readyState) a.onreadystatechange = null, b()
} : a.onload = function () {
b()
});
a.src = c;
document.body.appendChild(a)
};
(function () {
if ((typeof(device) != 'undefined') && (device.mobile())) {
document.getElementById("live2dcanvas").style.width = '75px';
document.getElementById("live2dcanvas").style.height = '150px';
} else if (typeof(device) === 'undefined') console.error('Cannot find current-device script.');
loadScript("/live2d/script.js", function () {
loadlive2d("live2dcanvas", "/live2d/assets/模型名.model.json", 0.5);
});
})();
</script>
More models
To obtain the model, you can go to live2d official website download and export by yourself
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。