-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
228 lines (213 loc) · 7.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=1900">
<title>Live2d V3 Demo</title>
<style>
html,
body {
margin: 0;
}
.form-control {
width: 300px;
height: calc(1.5em + .75rem + 2px);
padding: .375rem .75rem;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: .25rem;
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
.form-input {
width: 200px;
height: calc(1.2em+ 2px);
padding: .375rem .75rem;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: .25rem;
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
.btnGenericText {
white-space: nowrap;
height: 30px;
text-align: center;
vertical-align: middle;
display: table-cell;
background-color: #24252d;
border-style: solid;
border-color: #5c5d70;
border-width: 1px;
cursor: pointer;
padding: 0px 7px 0px 7px;
font-size: 14px;
color: white;
margin-bottom: 5px;
margin-left: 5px;
}
.selector {
width: 80%;
height: 90%;
position: absolute;
left: 10%;
background-color: #5c5d70;
overflow-y: auto;
padding: 10px;
border-radius: 3px;
}
.thumbbutton {
cursor: pointer;
height: 101px;
width: 180px;
display: inline-block;
margin-top: 20px;
margin-left: 20px;
border-radius: 3px;
}
</style>
<!-- Pollyfill script -->
<script src="https://unpkg.com/core-js-bundle@3.6.1/minified.js"></script>
<!-- Live2DCubismCore script -->
<script src="https://cubism.live2d.com/sdk-web/cubismcore/live2dcubismcore.min.js"></script>
<!-- Build script -->
<script src="./assets/js/live2dv3.js"></script>
</head>
<body style="text-align: center;background-color: rgb(73, 74, 90); color: white; overflow: auto;">
<div>
<div align="center" style="color: white;margin-bottom: 10px;">
<h1><a style="color: white;" href="https://github.com/jianchengwang/live2d_models">Live2D V3 Viewer</a></h1>
<div style="margin-top: 2px;">
You can find more model from
<a style="color: white;" href="https://github.com/alg-wiki/AzurLaneL2DViewer">
AzurLaneL2DViewer</a>
<a style="color: white;" href="https://github.com/Eikanya/Live2d-model">
Eikanya Live2d Model</a>
</div>
<select id="charSelect" class="form-control"
style="margin-top: 15px;background-color: #24252d; color: #ffffff;"></select>
<input class="form-input" readonly type="text" value="aierdeliqi_4" id="modelName" /><button
class="btnGenericText" style="height: 40px;" onclick="updateParentModel();">loadModel</button><br />
<div align="center" style="margin-top:15px; margin-bottom: 15px;">
<div class="btnGenericText" onclick="onSelectBG()" style="font-size: 17px; height: 40px;"><b>Change
Background</b>
</div>
</div>
<div id="motionDiv" style="margin-top: 5px;"></div>
<!-- 这里可以定义画布的大小位置 -->
<div id="L2dCanvas" class="live2d" style="position:block;margin:50px auto;z-index: -1;"></div>
<p style="position: relative;margin-top: 4rem;" data-v-b686e500="">
Design ❤️
<a style="color:teal;" href="https://github.com/jianchengwang" target="_blank" rel="noopener noreferrer"
class="underline text-tfh" data-v-b686e500="">JianchengWang
</a>
</p>
</body>
<script src="./assets/js/charData.js"></script>
<script src="./assets/js/backgroundData.js"></script>
<script type="text/javascript">
var l2dv;
window.onload = () => {
l2dv = new L2dViewer({
el: document.getElementById('L2dCanvas'),
modelHomePath: './assets/model/moc3/',
// modelHomePath: 'https://cdn.jsdelivr.net/gh/alg-wiki/AzurLaneL2DViewer@gh-pages/assets/',
model: 'aierdeliqi_4',
// bgImg: 'https://cdn.jsdelivr.net/gh/alg-wiki/AzurLaneL2DViewer@gh-pages/assets/bg/bg_church_jp.png',
bgImg: './assets/image/bg/bg_1.png',
autoMotion: false,
_finishedLoadModel: function () {
var motionDiv = document.getElementById("motionDiv");
motionDiv.innerHTML = "";
l2dv.getMotions().forEach((v, k) => {
let motionName = k;
if (motionName.startsWith('motions/')) {
motionName = motionName.replace('motions/', '');
}
motionName = motionName.replace('.motion3.json', '');
var bt = document.createElement("button");
bt.innerHTML = motionName;
bt.classList.add('btnGenericText');
bt.onclick = function () { //绑定点击事件
l2dv.startMotion(k);
};
motionDiv.appendChild(bt);
})
}
});
renderCharDataSelect();
}
function renderCharDataSelect() {
var charSelect = document.getElementById("charSelect");
for (let key in charData) {
var opt = document.createElement("option");
var _text = document.createTextNode(key);
opt.appendChild(_text);
opt.setAttribute("value", charData[key]);
charSelect.appendChild(opt);
}
charSelect.addEventListener("change", changeChar)
}
function changeChar() {
var charSelect = document.getElementById("charSelect");
var modelName = charSelect.options[charSelect.selectedIndex].value;
document.getElementById('modelName').value = modelName;
loadModel()
}
function loadModel() {
var modelName = document.getElementById('modelName').value;
l2dv.loadModel(modelName)
}
function updateParentModel() {
var modelName = document.getElementById('modelName').value;
window.opener.postMessage({ 'modelName': modelName }, '*')
alert('update parent model done.')
}
function onSelectBG() {
console.log(window.pageXOffset + " : " + window.pageYOffset);
var div = document.createElement('div');
div.className = "darken"; div.id = "darken";
div.style.top = window.pageYOffset + "px";
div.addEventListener("click", function (e) {
document.body.removeChild(document.getElementById("selector"));
document.body.removeChild(document.getElementById("darken"));
document.body.style.overflow = "auto";
}, false);
document.body.appendChild(div); document.body.style.overflow = "hidden";
var selector = document.createElement('div');
selector.id = "selector"; selector.className = "selector";
selector.style.top = (window.pageYOffset + (window.innerHeight * 0.05)) + "px";
document.body.appendChild(selector);
for (var i = 0; i < backgroundData.length; i++) {
var img = document.createElement('div'); img.className = "thumbbutton";
img.style.backgroundImage = "url(./assets/image/bg/" + backgroundData[i] + ")";
img.style.backgroundSize = "100%";
img.id = backgroundData[i];
img.addEventListener("click", function (e) {
l2dv.setBgImg("./assets/image/bg/" + this.id);
document.body.removeChild(document.getElementById("selector"));
document.body.removeChild(document.getElementById("darken"));
document.body.style.overflow = "auto";
}, false);
document.getElementById("selector").appendChild(img);
}
}
// aierdeliqi_4
// banrenma_2
// biaoqiang
// biaoqiang_3
// chuixue_3
// kelifulan_3
// lafei
// lafei_4
// xuefeng
</script>
</html>