Upload preprocess_manual.js
Browse files- preprocess_manual.js +45 -30
preprocess_manual.js
CHANGED
|
@@ -1178,6 +1178,12 @@ parser.parsePLY(gsPath, true).then((plyData) => {
|
|
| 1178 |
|
| 1179 |
console.log('[preprocessManual] ✓ PLY centered at origin');
|
| 1180 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1181 |
|
| 1182 |
// ========================================
|
| 1183 |
// STEP 2: バウンディングボックスを再計算
|
|
@@ -1185,7 +1191,7 @@ parser.parsePLY(gsPath, true).then((plyData) => {
|
|
| 1185 |
console.log('[preprocessManual] Step 2: Recalculating bounding box...');
|
| 1186 |
let minX = Infinity, minY = Infinity, minZ = Infinity;
|
| 1187 |
let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;
|
| 1188 |
-
|
| 1189 |
plyData.vertices.forEach(v => {
|
| 1190 |
minX = Math.min(minX, v.x);
|
| 1191 |
minY = Math.min(minY, v.y);
|
|
@@ -1194,17 +1200,20 @@ parser.parsePLY(gsPath, true).then((plyData) => {
|
|
| 1194 |
maxY = Math.max(maxY, v.y);
|
| 1195 |
maxZ = Math.max(maxZ, v.z);
|
| 1196 |
});
|
| 1197 |
-
|
|
|
|
| 1198 |
const sizeX = maxX - minX;
|
| 1199 |
const sizeY = maxY - minY;
|
| 1200 |
const sizeZ = maxZ - minZ;
|
| 1201 |
-
|
| 1202 |
console.log('[preprocessManual] Centered sizes:', {
|
| 1203 |
sizeX: sizeX.toFixed(2),
|
| 1204 |
sizeY: sizeY.toFixed(2),
|
| 1205 |
sizeZ: sizeZ.toFixed(2)
|
| 1206 |
});
|
| 1207 |
-
|
|
|
|
|
|
|
| 1208 |
// ========================================
|
| 1209 |
// STEP 3: Y軸が最長になるように回転
|
| 1210 |
// ========================================
|
|
@@ -1356,46 +1365,52 @@ parser.parsePLY(gsPath, true).then((plyData) => {
|
|
| 1356 |
// ⭐ 4. カメラをPLYに合わせて調整(cameraControls初期化後)
|
| 1357 |
// ========================================
|
| 1358 |
|
| 1359 |
-
|
| 1360 |
|
| 1361 |
console.log('[preprocessManual] Auto-aligning camera to PLY...');
|
| 1362 |
|
| 1363 |
-
// ⭐⭐⭐
|
| 1364 |
-
|
| 1365 |
-
let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;
|
| 1366 |
-
|
| 1367 |
-
plyData.vertices.forEach(vertex => {
|
| 1368 |
-
minX = Math.min(minX, vertex.x);
|
| 1369 |
-
minY = Math.min(minY, vertex.y);
|
| 1370 |
-
minZ = Math.min(minZ, vertex.z);
|
| 1371 |
-
maxX = Math.max(maxX, vertex.x);
|
| 1372 |
-
maxY = Math.max(maxY, vertex.y);
|
| 1373 |
-
maxZ = Math.max(maxZ, vertex.z);
|
| 1374 |
-
});
|
| 1375 |
-
|
| 1376 |
-
const center = {
|
| 1377 |
-
x: (maxX + minX) / 2, // ← ほぼ 0 になる
|
| 1378 |
-
y: (maxY + minY) / 2,
|
| 1379 |
-
z: (maxZ + minZ) / 2
|
| 1380 |
-
};
|
| 1381 |
|
|
|
|
| 1382 |
const size = {
|
| 1383 |
-
x:
|
| 1384 |
-
y:
|
| 1385 |
-
z:
|
| 1386 |
};
|
| 1387 |
|
| 1388 |
console.log('[preprocessManual] Camera alignment - PLY center:', center);
|
| 1389 |
console.log('[preprocessManual] Camera alignment - PLY size:', size);
|
| 1390 |
-
|
| 1391 |
-
|
| 1392 |
-
//////////////////////ここまで
|
| 1393 |
|
| 1394 |
const maxDim = Math.max(size.x, size.y, size.z);
|
| 1395 |
-
|
| 1396 |
// カメラ位置を計算
|
| 1397 |
const distance = maxDim * 2.0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1398 |
|
|
|
|
|
|
|
|
|
|
| 1399 |
camera.position.set(
|
| 1400 |
center.x,
|
| 1401 |
center.y + maxDim * 0.3,
|
|
|
|
| 1178 |
|
| 1179 |
console.log('[preprocessManual] ✓ PLY centered at origin');
|
| 1180 |
|
| 1181 |
+
// ⭐⭐⭐ センタリング後の中心を保存 ⭐⭐⭐
|
| 1182 |
+
const centeredCenter = { x: 0, y: 0, z: 0 }; // センタリング後は必ず 0,0,0
|
| 1183 |
+
|
| 1184 |
+
/////////////////10:08
|
| 1185 |
+
|
| 1186 |
+
////////////10:13 start
|
| 1187 |
|
| 1188 |
// ========================================
|
| 1189 |
// STEP 2: バウンディングボックスを再計算
|
|
|
|
| 1191 |
console.log('[preprocessManual] Step 2: Recalculating bounding box...');
|
| 1192 |
let minX = Infinity, minY = Infinity, minZ = Infinity;
|
| 1193 |
let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;
|
| 1194 |
+
|
| 1195 |
plyData.vertices.forEach(v => {
|
| 1196 |
minX = Math.min(minX, v.x);
|
| 1197 |
minY = Math.min(minY, v.y);
|
|
|
|
| 1200 |
maxY = Math.max(maxY, v.y);
|
| 1201 |
maxZ = Math.max(maxZ, v.z);
|
| 1202 |
});
|
| 1203 |
+
|
| 1204 |
+
// ⭐ const を削除して、後で使えるようにする
|
| 1205 |
const sizeX = maxX - minX;
|
| 1206 |
const sizeY = maxY - minY;
|
| 1207 |
const sizeZ = maxZ - minZ;
|
| 1208 |
+
|
| 1209 |
console.log('[preprocessManual] Centered sizes:', {
|
| 1210 |
sizeX: sizeX.toFixed(2),
|
| 1211 |
sizeY: sizeY.toFixed(2),
|
| 1212 |
sizeZ: sizeZ.toFixed(2)
|
| 1213 |
});
|
| 1214 |
+
|
| 1215 |
+
////////////10:13 end
|
| 1216 |
+
|
| 1217 |
// ========================================
|
| 1218 |
// STEP 3: Y軸が最長になるように回転
|
| 1219 |
// ========================================
|
|
|
|
| 1365 |
// ⭐ 4. カメラをPLYに合わせて調整(cameraControls初期化後)
|
| 1366 |
// ========================================
|
| 1367 |
|
| 1368 |
+
//////////////////////10:10
|
| 1369 |
|
| 1370 |
console.log('[preprocessManual] Auto-aligning camera to PLY...');
|
| 1371 |
|
| 1372 |
+
// ⭐⭐⭐ センタリング後の中心は常に 0,0,0 ⭐⭐⭐
|
| 1373 |
+
const center = { x: 0, y: 0, z: 0 };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1374 |
|
| 1375 |
+
// Step 2 で計算したサイズを使用
|
| 1376 |
const size = {
|
| 1377 |
+
x: sizeX, // Step 2 で計算済み
|
| 1378 |
+
y: sizeY,
|
| 1379 |
+
z: sizeZ
|
| 1380 |
};
|
| 1381 |
|
| 1382 |
console.log('[preprocessManual] Camera alignment - PLY center:', center);
|
| 1383 |
console.log('[preprocessManual] Camera alignment - PLY size:', size);
|
|
|
|
|
|
|
|
|
|
| 1384 |
|
| 1385 |
const maxDim = Math.max(size.x, size.y, size.z);
|
| 1386 |
+
|
| 1387 |
// カメラ位置を計算
|
| 1388 |
const distance = maxDim * 2.0;
|
| 1389 |
+
|
| 1390 |
+
camera.position.set(
|
| 1391 |
+
center.x,
|
| 1392 |
+
center.y + maxDim * 0.3,
|
| 1393 |
+
center.z + distance
|
| 1394 |
+
);
|
| 1395 |
+
|
| 1396 |
+
camera.lookAt(center.x, center.y, center.z);
|
| 1397 |
+
camera.updateProjectionMatrix();
|
| 1398 |
+
|
| 1399 |
+
console.log('[preprocessManual] Camera positioned at:', {
|
| 1400 |
+
x: camera.position.x.toFixed(2),
|
| 1401 |
+
y: camera.position.y.toFixed(2),
|
| 1402 |
+
z: camera.position.z.toFixed(2)
|
| 1403 |
+
});
|
| 1404 |
+
console.log('[preprocessManual] Looking at:', center);
|
| 1405 |
+
|
| 1406 |
+
// ⭐ OrbitControlsのターゲットを設定
|
| 1407 |
+
cameraControls.controls.target.set(center.x, center.y, center.z);
|
| 1408 |
+
cameraControls.controls.update();
|
| 1409 |
+
console.log('[preprocessManual] OrbitControls target set to PLY center');
|
| 1410 |
|
| 1411 |
+
//////////////////////ここまで
|
| 1412 |
+
|
| 1413 |
+
|
| 1414 |
camera.position.set(
|
| 1415 |
center.x,
|
| 1416 |
center.y + maxDim * 0.3,
|