2
2
// 兼容低版本浏览器
3
3
document . write ( '<script src="https://unpkg.com/[email protected] /minified.js"></script>' ) ;
4
4
// 音频播放
5
- document . write ( '<script src="https://cdn.jsdelivr.net/npm/[email protected] /dist/howler.min.js"></script>' ) ;
5
+ // document.write('<script src="https://cdn.jsdelivr.net/npm/[email protected] /dist/howler.min.js"></script>');
6
6
// 必需
7
- document . write ( '<script src="https://cubism.live2d.com/sdk-web/cubismcore/live2dcubismcore.min.js"></script>' ) ;
7
+ // document.write('<script src="https://cubism.live2d.com/sdk-web/cubismcore/live2dcubismcore.min.js"></script>');
8
+ document . write ( '<script src="https://cdn.jsdelivr.net/gh/jianchengwang/live2d_models@main/assets/js/lib/live2dcubismcore.min.js"></script>' ) ;
8
9
// live2dv3.js
9
10
document . write ( '<script src="https://cdn.jsdelivr.net/gh/jianchengwang/live2d_models@main/assets/js/live2dv3.js"></script>' ) ;
10
11
// 内置角色
@@ -14,7 +15,7 @@ document.write('<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-a
14
15
document . write ( '<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/jianchengwang/live2d_models@main/assets/css/live2dv3.init.css">' ) ;
15
16
16
17
// 创建看板娘div
17
- document . write (
18
+ document . write (
18
19
`<div id="l2d-toggle" class="" style="visibility:hidden;">
19
20
<span>看版娘</span>
20
21
</div>
@@ -41,7 +42,7 @@ window.onload = () => {
41
42
// 创建l2dv
42
43
var l2dv
43
44
function createL2dv ( ) {
44
- if ( ! l2dv ) {
45
+ if ( ! l2dv ) {
45
46
l2dv = new L2dViewer ( {
46
47
el : document . getElementById ( 'L2dCanvas' ) ,
47
48
// modelHomePath: './assets/model/',
@@ -60,7 +61,7 @@ function createL2dv() {
60
61
} , 2000 ) ;
61
62
}
62
63
// 注册事件
63
- registerEventListener ( ) ;
64
+ registerEventListener ( ) ;
64
65
}
65
66
66
67
// 监听事件
@@ -89,7 +90,7 @@ function registerEventListener() {
89
90
document . getElementById ( "l2d-toggle" ) . addEventListener ( "click" , showModel ) ;
90
91
91
92
// other
92
- const devtools = ( ) => { } ;
93
+ const devtools = ( ) => { } ;
93
94
console . log ( "%c" , devtools ) ;
94
95
devtools . toString = ( ) => {
95
96
showMessage ( "哈哈,你打开了控制台,是想要看看我的小秘密吗?" , 4000 , 9 ) ;
@@ -126,16 +127,16 @@ function showModel() {
126
127
// 加载model
127
128
function loadModel ( modelName ) {
128
129
showMessage ( "正在切换看板娘..." , 6000 , 1 ) ;
129
- if ( modelName instanceof MouseEvent ) {
130
+ if ( modelName instanceof MouseEvent ) {
130
131
modelName = randomChar ( ) ;
131
- } else if ( ! modelName ) {
132
- if ( document . getElementById ( 'modelName' ) ) {
132
+ } else if ( ! modelName ) {
133
+ if ( document . getElementById ( 'modelName' ) ) {
133
134
modelName = document . getElementById ( 'modelName' ) . value
134
135
} else {
135
136
modelName = randomChar ( ) ;
136
137
}
137
138
}
138
- console . info ( modelName + ' loading....' )
139
+ console . info ( modelName + ' loading....' )
139
140
l2dv . loadModel ( modelName )
140
141
}
141
142
@@ -162,7 +163,7 @@ function showHitokoto() {
162
163
// 显示tip消息
163
164
function showMessage ( text , timeout , priority ) {
164
165
if ( ! text ) return ;
165
- if ( ! timeout ) timeout = 1000 ;
166
+ if ( ! timeout ) timeout = 1000 ;
166
167
const tips = document . getElementById ( "l2d-tips" ) ;
167
168
tips . innerHTML = text ;
168
169
tips . classList . add ( "l2d-tips-active" ) ;
@@ -171,4 +172,3 @@ function showMessage(text, timeout, priority) {
171
172
tips . classList . remove ( "l2d-tips-active" ) ;
172
173
} , timeout ) ;
173
174
}
174
-
0 commit comments