-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodel-test.html
More file actions
351 lines (324 loc) · 12.9 KB
/
model-test.html
File metadata and controls
351 lines (324 loc) · 12.9 KB
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D模型测试 - Beacon World App</title>
<script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
background: #f5f5f5;
}
.container {
max-width: 1000px;
margin: 0 auto;
background: white;
padding: 20px;
border-radius: 10px;
}
h1 {
color: #333;
text-align: center;
}
.test-section {
margin: 30px 0;
padding: 20px;
background: #f9f9f9;
border-radius: 8px;
}
.model-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
margin-top: 20px;
}
.model-test {
background: white;
border-radius: 8px;
padding: 15px;
border: 2px solid #ddd;
text-align: center;
}
.model-test.success {
border-color: #28a745;
}
.model-test.error {
border-color: #dc3545;
}
model-viewer {
width: 100%;
height: 200px;
background-color: #f0f0f0;
border-radius: 8px;
}
.model-info {
margin-top: 10px;
font-size: 14px;
}
.model-path {
font-family: monospace;
background: #e9ecef;
padding: 5px;
border-radius: 3px;
margin: 5px 0;
word-break: break-all;
}
.status {
margin-top: 10px;
padding: 8px;
border-radius: 4px;
font-weight: bold;
}
.status.loading {
background: #fff3cd;
color: #856404;
}
.status.success {
background: #d4edda;
color: #155724;
}
.status.error {
background: #f8d7da;
color: #721c24;
}
.file-check {
margin: 10px 0;
padding: 10px;
background: white;
border-radius: 5px;
border-left: 4px solid #ddd;
}
.file-check.success {
border-left-color: #28a745;
}
.file-check.error {
border-left-color: #dc3545;
}
button {
background: #007bff;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
margin: 5px;
}
button:hover {
background: #0056b3;
}
</style>
</head>
<body>
<div class="container">
<h1>🎮 3D模型测试页面</h1>
<div class="test-section">
<h3>📍 页面信息</h3>
<p><strong>当前URL:</strong> <span id="current-url"></span></p>
<p><strong>Base URL:</strong> <span id="base-url"></span></p>
</div>
<div class="test-section">
<h3>📁 模型文件检查</h3>
<div id="file-checks">正在检查文件...</div>
<button onclick="checkFiles()">🔄 重新检查文件</button>
</div>
<div class="test-section">
<h3>🎮 3D模型加载测试</h3>
<p>以下是应用中使用的3D模型文件测试:</p>
<div class="model-container">
<!-- Bommie Boy 模型 -->
<div class="model-test" id="bommieBoy-test">
<h4>Bommie Boy</h4>
<model-viewer
id="bommieBoy-viewer"
src="assets/assets/models/bommieBoy.glb"
alt="Bommie Boy 3D Model"
auto-rotate
camera-controls
background-color="#f0f0f0">
</model-viewer>
<div class="model-info">
<div class="model-path">assets/assets/models/bommieBoy.glb</div>
<div class="status loading" id="bommieBoy-status">加载中...</div>
</div>
</div>
<!-- Bommie Girl 模型 -->
<div class="model-test" id="bommieGirl-test">
<h4>Bommie Girl</h4>
<model-viewer
id="bommieGirl-viewer"
src="assets/assets/models/bommieGirl.glb"
alt="Bommie Girl 3D Model"
auto-rotate
camera-controls
background-color="#f0f0f0">
</model-viewer>
<div class="model-info">
<div class="model-path">assets/assets/models/bommieGirl.glb</div>
<div class="status loading" id="bommieGirl-status">加载中...</div>
</div>
</div>
<!-- Bommie 基础模型 -->
<div class="model-test" id="bommie-test">
<h4>Bommie</h4>
<model-viewer
id="bommie-viewer"
src="assets/assets/models/bommie.glb"
alt="Bommie 3D Model"
auto-rotate
camera-controls
background-color="#f0f0f0">
</model-viewer>
<div class="model-info">
<div class="model-path">assets/assets/models/bommie.glb</div>
<div class="status loading" id="bommie-status">加载中...</div>
</div>
</div>
</div>
</div>
<div class="test-section">
<h3>📊 测试结果</h3>
<div id="results">等待测试完成...</div>
</div>
<div class="test-section">
<h3>🔧 解决方案</h3>
<div id="solutions"></div>
</div>
<p><a href="index.html">🏠 返回主应用</a> | <a href="debug.html">🔧 调试页面</a></p>
</div>
<script>
// 更新页面信息
document.getElementById('current-url').textContent = window.location.href;
document.getElementById('base-url').textContent = window.location.origin + window.location.pathname.replace(/[^/]*$/, '');
const modelFiles = [
'assets/assets/models/bommieBoy.glb',
'assets/assets/models/bommieGirl.glb',
'assets/assets/models/bommie.glb'
];
let testResults = {
fileSuccess: 0,
fileError: 0,
modelSuccess: 0,
modelError: 0
};
// 检查文件是否存在
async function checkFiles() {
const container = document.getElementById('file-checks');
container.innerHTML = '';
for (const file of modelFiles) {
try {
const response = await fetch(file, { method: 'HEAD' });
const div = document.createElement('div');
div.className = response.ok ? 'file-check success' : 'file-check error';
if (response.ok) {
const size = response.headers.get('content-length');
div.innerHTML = `✅ ${file} - 状态: ${response.status}, 大小: ${size ? (parseInt(size) / 1024 / 1024).toFixed(2) + ' MB' : '未知'}`;
testResults.fileSuccess++;
} else {
div.innerHTML = `❌ ${file} - 状态: ${response.status}`;
testResults.fileError++;
}
container.appendChild(div);
} catch (error) {
const div = document.createElement('div');
div.className = 'file-check error';
div.innerHTML = `❌ ${file} - 错误: ${error.message}`;
container.appendChild(div);
testResults.fileError++;
}
}
updateResults();
}
// 设置模型加载事件监听器
function setupModelListeners() {
const models = ['bommieBoy', 'bommieGirl', 'bommie'];
models.forEach(modelName => {
const viewer = document.getElementById(`${modelName}-viewer`);
const status = document.getElementById(`${modelName}-status`);
const container = document.getElementById(`${modelName}-test`);
viewer.addEventListener('load', () => {
status.textContent = '✅ 加载成功';
status.className = 'status success';
container.className = 'model-test success';
testResults.modelSuccess++;
updateResults();
});
viewer.addEventListener('error', (event) => {
status.textContent = '❌ 加载失败';
status.className = 'status error';
container.className = 'model-test error';
testResults.modelError++;
updateResults();
console.error(`Model ${modelName} failed to load:`, event);
});
});
}
function updateResults() {
const container = document.getElementById('results');
container.innerHTML = `
<p><strong>文件检查:</strong> 成功 ${testResults.fileSuccess}, 失败 ${testResults.fileError}</p>
<p><strong>模型加载:</strong> 成功 ${testResults.modelSuccess}, 失败 ${testResults.modelError}</p>
`;
updateSolutions();
}
function updateSolutions() {
const container = document.getElementById('solutions');
if (testResults.fileError > 0) {
container.innerHTML = `
<div class="file-check error">
<h4>❌ 模型文件缺失</h4>
<p>有 ${testResults.fileError} 个模型文件无法访问。</p>
<p><strong>解决方案:</strong></p>
<ol>
<li>确保所有 .glb 文件都已上传到GitHub仓库</li>
<li>检查文件大小是否超过GitHub限制 (100MB)</li>
<li>确保文件路径正确: assets/assets/models/</li>
<li>等待GitHub Pages更新 (5-10分钟)</li>
<li>如果文件过大,考虑使用Git LFS</li>
</ol>
</div>
`;
} else if (testResults.modelError > 0) {
container.innerHTML = `
<div class="file-check error">
<h4>⚠️ 模型加载失败</h4>
<p>文件存在但模型无法正确加载。</p>
<p><strong>可能原因:</strong></p>
<ul>
<li>GLB文件损坏</li>
<li>浏览器不支持WebGL</li>
<li>model-viewer库加载失败</li>
</ul>
</div>
`;
} else if (testResults.fileSuccess > 0 && testResults.modelSuccess > 0) {
container.innerHTML = `
<div class="file-check success">
<h4>🎉 所有模型测试通过!</h4>
<p>所有3D模型文件都能正常访问和加载。</p>
<p>如果主应用中仍然有问题,可能是代码中的路径配置问题。</p>
</div>
`;
}
}
// 页面加载完成后开始测试
window.addEventListener('load', () => {
setupModelListeners();
checkFiles();
// 10秒后检查模型加载状态
setTimeout(() => {
const loadingStatuses = document.querySelectorAll('.status.loading');
loadingStatuses.forEach(status => {
if (status.className.includes('loading')) {
status.textContent = '⏰ 加载超时';
status.className = 'status error';
testResults.modelError++;
}
});
updateResults();
}, 10000);
});
</script>
</body>
</html>