update: 新增模型加载

This commit is contained in:
lww155
2026-01-15 09:20:22 +08:00
parent fa31096cd8
commit 778c4560fd
4 changed files with 118 additions and 1 deletions
+11
View File
@@ -37,9 +37,20 @@ class App {
// 初始化Live2D
await this.initLive2D();
// 关闭加载loading
this.setModelLoadingStatus(false);
log('应用初始化完成', 'success');
}
// 设置model加载状态
setModelLoadingStatus(isLoading) {
const modelLoading = document.getElementById('modelLoading');
if (modelLoading) {
modelLoading.style.display = isLoading ? 'flex' : 'none';
}
}
// 初始化Live2D
async initLive2D() {
try {
@@ -0,0 +1,15 @@
// 背景图加载检测
const backgroundContainer = document.getElementById('backgroundContainer');
// 提取背景图片URL
let bgImageUrl = window.getComputedStyle(backgroundContainer).backgroundImage;
const urlMatch = bgImageUrl.match(/url\(["']?(.*?)["']?\)/);
bgImageUrl = urlMatch[1];
const bgImage = new Image();
bgImage.src = bgImageUrl;
// 加载完成后显示模型加载
bgImage.onload = function () {
const modelLoading = document.getElementById('modelLoading');
if (modelLoading) {
modelLoading.style.display = 'flex';
}
}