live2d-canvas
v0.0.1
Published
```html <!DOCTYPE html> <html>
Readme
我的第一个HTML页面
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>文档标题</title>
<style>
html, body {
margin: 0;
overflow: hidden;
}
canvas {
width: 100vw;
height: 100vh;
display: block;
}
</style>
</head>
<body>
<h1>我的第一个HTML页面</h1>
<p>我的第一个段落。</p>
<script src="//cdn.jsdelivr.net/npm/[email protected]/dist/Core/live2dcubismcore.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/[email protected]/dist/index.js" type="module"></script>
<script type="module">
console.log(window.Live2d)
const Live2d = window.Live2d
window.addEventListener(
'load',
() => {
let model = "Mao"
Live2d.launchLive2d({
ResourcesPath: 'https://cdn.jsdelivr.net/npm/[email protected]/dist/Resources/',
BackImageName: 'back_class_normal.png',
Model: model,
MessageStyle: {
width: '100%',
backgroundColor: 'white',
top: '95%',
}
})
Live2d.loadVoice(model, "https://www.1micro.top/alist/d/audio.wav").then(dateBytes => {
setTimeout(() => {
Live2d.setExpression(model, "exp_08")
Live2d.setMessageBox("哟哟哟~", 6000)
const music = new Audio('audio.wav')
music.crossOrigin = "anonymous";
music.addEventListener('play', function () {
Live2d.mouthMotions(model, dateBytes, 2.0)
})
music.addEventListener('ended', function() {
music.play()
});
music.play()
}, 3000)
})
}, { passive: true }
);
</script>
</body>
</html>