-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglb-helper.html
More file actions
323 lines (307 loc) · 11.2 KB
/
glb-helper.html
File metadata and controls
323 lines (307 loc) · 11.2 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
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GLB Helper - モデル情報確認ツール</title>
<style>
body {
margin: 0;
padding: 20px;
font-family: 'Segoe UI', Arial, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
}
.container {
max-width: 1200px;
margin: 0 auto;
background: white;
border-radius: 12px;
padding: 30px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
h1 {
color: #333;
margin-top: 0;
text-align: center;
font-size: 32px;
}
.models {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 30px;
margin-top: 30px;
}
.model-card {
border: 2px solid #e0e0e0;
border-radius: 8px;
padding: 20px;
background: #f9f9f9;
}
.model-card h2 {
margin-top: 0;
color: #667eea;
font-size: 24px;
}
.info-section {
margin: 15px 0;
padding: 15px;
background: white;
border-radius: 6px;
border-left: 4px solid #667eea;
}
.info-section h3 {
margin: 0 0 10px 0;
color: #555;
font-size: 16px;
font-weight: 600;
}
.info-row {
display: flex;
justify-content: space-between;
padding: 8px 0;
border-bottom: 1px solid #eee;
}
.info-row:last-child {
border-bottom: none;
}
.info-label {
font-weight: 600;
color: #666;
}
.info-value {
color: #333;
font-family: 'Courier New', monospace;
}
.status {
padding: 10px;
margin: 20px 0;
border-radius: 6px;
text-align: center;
font-weight: 600;
}
.status.loading {
background: #fff3cd;
color: #856404;
}
.status.success {
background: #d4edda;
color: #155724;
}
.status.error {
background: #f8d7da;
color: #721c24;
}
.bones-list {
max-height: 200px;
overflow-y: auto;
background: #f5f5f5;
padding: 10px;
border-radius: 4px;
font-family: 'Courier New', monospace;
font-size: 12px;
}
.highlight {
background: #fff3cd;
padding: 2px 6px;
border-radius: 3px;
font-weight: bold;
}
@media (max-width: 768px) {
.models {
grid-template-columns: 1fr;
}
}
</style>
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/three@0.160.0/build/three.module.js",
"three/addons/": "https://unpkg.com/three@0.160.0/examples/jsm/"
}
}
</script>
</head>
<body>
<div class="container">
<h1>🔍 GLB Helper - モデル情報確認ツール</h1>
<div class="status loading" id="status">モデルを読み込み中...</div>
<div class="models">
<div class="model-card">
<h2>👨 男性モデル (model.glb)</h2>
<div id="male-info">読み込み中...</div>
</div>
<div class="model-card">
<h2>👩 女性モデル (model_female.glb)</h2>
<div id="female-info">読み込み中...</div>
</div>
</div>
</div>
<script type="module">
import * as THREE from 'three';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
const loader = new GLTFLoader();
const statusEl = document.getElementById('status');
let loadedCount = 0;
function analyzeModel(gltf, name) {
const model = gltf.scene;
const box = new THREE.Box3().setFromObject(model);
const size = new THREE.Vector3();
const center = new THREE.Vector3();
box.getSize(size);
box.getCenter(center);
const bones = [];
const meshes = [];
let vertexCount = 0;
let triangleCount = 0;
model.traverse(obj => {
if (obj.isBone) {
bones.push(obj.name);
}
if (obj.isMesh) {
meshes.push(obj.name);
if (obj.geometry) {
const positions = obj.geometry.attributes.position;
if (positions) {
vertexCount += positions.count;
}
const index = obj.geometry.index;
if (index) {
triangleCount += index.count / 3;
} else if (positions) {
triangleCount += positions.count / 3;
}
}
}
});
const sphere = new THREE.Sphere();
box.getBoundingSphere(sphere);
return {
name,
dimensions: {
width: size.x,
height: size.y,
depth: size.z
},
center: {
x: center.x,
y: center.y,
z: center.z
},
bounds: {
min: { x: box.min.x, y: box.min.y, z: box.min.z },
max: { x: box.max.x, y: box.max.y, z: box.max.z }
},
radius: sphere.radius,
bones: bones,
meshes: meshes,
stats: {
vertexCount,
triangleCount: Math.round(triangleCount)
}
};
}
function formatNumber(num) {
return num.toFixed(4);
}
function renderModelInfo(info, containerId) {
const container = document.getElementById(containerId);
const html = `
<div class="info-section">
<h3>📏 寸法情報</h3>
<div class="info-row">
<span class="info-label">高さ (Height Y):</span>
<span class="info-value highlight">${formatNumber(info.dimensions.height)} m</span>
</div>
<div class="info-row">
<span class="info-label">幅 (Width X):</span>
<span class="info-value">${formatNumber(info.dimensions.width)} m</span>
</div>
<div class="info-row">
<span class="info-label">奥行 (Depth Z):</span>
<span class="info-value">${formatNumber(info.dimensions.depth)} m</span>
</div>
<div class="info-row">
<span class="info-label">バウンディング半径:</span>
<span class="info-value">${formatNumber(info.radius)} m</span>
</div>
</div>
<div class="info-section">
<h3>📍 中心座標</h3>
<div class="info-row">
<span class="info-label">X:</span>
<span class="info-value">${formatNumber(info.center.x)}</span>
</div>
<div class="info-row">
<span class="info-label">Y:</span>
<span class="info-value">${formatNumber(info.center.y)}</span>
</div>
<div class="info-row">
<span class="info-label">Z:</span>
<span class="info-value">${formatNumber(info.center.z)}</span>
</div>
</div>
<div class="info-section">
<h3>🦴 骨格情報</h3>
<div class="info-row">
<span class="info-label">ボーン数:</span>
<span class="info-value">${info.bones.length}</span>
</div>
<div class="bones-list">
${info.bones.length > 0 ? info.bones.join('<br>') : 'ボーンが見つかりません'}
</div>
</div>
<div class="info-section">
<h3>📊 メッシュ情報</h3>
<div class="info-row">
<span class="info-label">メッシュ数:</span>
<span class="info-value">${info.meshes.length}</span>
</div>
<div class="info-row">
<span class="info-label">頂点数:</span>
<span class="info-value">${info.stats.vertexCount.toLocaleString()}</span>
</div>
<div class="info-row">
<span class="info-label">三角形数:</span>
<span class="info-value">${info.stats.triangleCount.toLocaleString()}</span>
</div>
</div>
`;
container.innerHTML = html;
}
function updateStatus() {
loadedCount++;
if (loadedCount === 2) {
statusEl.className = 'status success';
statusEl.textContent = '✅ 両方のモデルを正常に読み込みました!';
}
}
// 男性モデルを読み込み
loader.load('./model.glb', (gltf) => {
console.log('男性モデル読み込み成功');
const info = analyzeModel(gltf, '男性モデル');
console.log('男性モデル情報:', info);
renderModelInfo(info, 'male-info');
updateStatus();
}, undefined, (err) => {
console.error('男性モデル読み込み失敗:', err);
document.getElementById('male-info').innerHTML =
'<div class="status error">⚠️ model.glb の読み込みに失敗しました</div>';
updateStatus();
});
// 女性モデルを読み込み
loader.load('./model_female.glb', (gltf) => {
console.log('女性モデル読み込み成功');
const info = analyzeModel(gltf, '女性モデル');
console.log('女性モデル情報:', info);
renderModelInfo(info, 'female-info');
updateStatus();
}, undefined, (err) => {
console.error('女性モデル読み込み失敗:', err);
document.getElementById('female-info').innerHTML =
'<div class="status error">⚠️ model_female.glb の読み込みに失敗しました</div>';
updateStatus();
});
</script>
</body>
</html>