Upload preprocess_manual.js
Browse files- preprocess_manual.js +0 -104
preprocess_manual.js
CHANGED
|
@@ -1351,110 +1351,6 @@ console.log('[preprocessManual] ===== AUTO-ALIGNMENT COMPLETE =====');
|
|
| 1351 |
// ========================================
|
| 1352 |
|
| 1353 |
|
| 1354 |
-
///////////////START1137
|
| 1355 |
-
|
| 1356 |
-
|
| 1357 |
-
// ========================================
|
| 1358 |
-
// VERIFICATION ONLY - Do not re-center!
|
| 1359 |
-
// ========================================
|
| 1360 |
-
console.log('[preprocessManual] Verifying PLY is centered at origin...');
|
| 1361 |
-
|
| 1362 |
-
let minX = Infinity, minY = Infinity, minZ = Infinity;
|
| 1363 |
-
let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;
|
| 1364 |
-
|
| 1365 |
-
plyData.vertices.forEach(vertex => {
|
| 1366 |
-
minX = Math.min(minX, vertex.x);
|
| 1367 |
-
minY = Math.min(minY, vertex.y);
|
| 1368 |
-
minZ = Math.min(minZ, vertex.z);
|
| 1369 |
-
maxX = Math.max(maxX, vertex.x);
|
| 1370 |
-
maxY = Math.max(maxY, vertex.y);
|
| 1371 |
-
maxZ = Math.max(maxZ, vertex.z);
|
| 1372 |
-
});
|
| 1373 |
-
|
| 1374 |
-
const verifiedCenter = {
|
| 1375 |
-
x: (maxX + minX) / 2,
|
| 1376 |
-
y: (maxY + minY) / 2,
|
| 1377 |
-
z: (maxZ + minZ) / 2
|
| 1378 |
-
};
|
| 1379 |
-
|
| 1380 |
-
console.log('[preprocessManual] Verified bounds:');
|
| 1381 |
-
console.log(' Min:', { x: minX.toFixed(3), y: minY.toFixed(3), z: minZ.toFixed(3) });
|
| 1382 |
-
console.log(' Max:', { x: maxX.toFixed(3), y: maxY.toFixed(3), z: maxZ.toFixed(3) });
|
| 1383 |
-
console.log(' Center:', {
|
| 1384 |
-
x: verifiedCenter.x.toFixed(6),
|
| 1385 |
-
y: verifiedCenter.y.toFixed(6),
|
| 1386 |
-
z: verifiedCenter.z.toFixed(6)
|
| 1387 |
-
});
|
| 1388 |
-
|
| 1389 |
-
// STRICT VERIFICATION - Must be within 1mm tolerance
|
| 1390 |
-
const tolerance = 0.001; // 1mm
|
| 1391 |
-
if (Math.abs(verifiedCenter.x) > tolerance ||
|
| 1392 |
-
Math.abs(verifiedCenter.y) > tolerance ||
|
| 1393 |
-
Math.abs(verifiedCenter.z) > tolerance) {
|
| 1394 |
-
console.error('[preprocessManual] ❌ CRITICAL ERROR: PLY centering verification FAILED!');
|
| 1395 |
-
console.error('[preprocessManual] Center is NOT at origin:', verifiedCenter);
|
| 1396 |
-
console.error('[preprocessManual] This means Step 2 centering did not work!');
|
| 1397 |
-
|
| 1398 |
-
alert('❌ CRITICAL ERROR: PLY Centering Failed!\n\n' +
|
| 1399 |
-
'Expected: (0, 0, 0)\n' +
|
| 1400 |
-
'Got: (' + verifiedCenter.x.toFixed(6) + ', ' +
|
| 1401 |
-
verifiedCenter.y.toFixed(6) + ', ' +
|
| 1402 |
-
verifiedCenter.z.toFixed(6) + ')\n\n' +
|
| 1403 |
-
'The vertices were modified between Step 2 and now.\n' +
|
| 1404 |
-
'Please reload the page and do NOT modify the code between steps.');
|
| 1405 |
-
return; // STOP execution
|
| 1406 |
-
}
|
| 1407 |
-
|
| 1408 |
-
console.log('[preprocessManual] ✓ Verification PASSED - Center is at origin');
|
| 1409 |
-
|
| 1410 |
-
// ========================================
|
| 1411 |
-
// Camera Setup (using verified bounds)
|
| 1412 |
-
// ========================================
|
| 1413 |
-
const size = {
|
| 1414 |
-
x: maxX - minX,
|
| 1415 |
-
y: maxY - minY,
|
| 1416 |
-
z: maxZ - minZ
|
| 1417 |
-
};
|
| 1418 |
-
|
| 1419 |
-
const maxDim = Math.max(size.x, size.y, size.z);
|
| 1420 |
-
const distance = maxDim * 2.0;
|
| 1421 |
-
|
| 1422 |
-
// Camera always looks at 0,0,0 (the guaranteed center)
|
| 1423 |
-
camera.position.set(0, maxDim * 0.3, distance);
|
| 1424 |
-
camera.lookAt(0, 0, 0);
|
| 1425 |
-
camera.updateProjectionMatrix();
|
| 1426 |
-
|
| 1427 |
-
console.log('[preprocessManual] Camera positioned at:', {
|
| 1428 |
-
x: camera.position.x.toFixed(2),
|
| 1429 |
-
y: camera.position.y.toFixed(2),
|
| 1430 |
-
z: camera.position.z.toFixed(2)
|
| 1431 |
-
});
|
| 1432 |
-
console.log('[preprocessManual] Looking at: (0, 0, 0)');
|
| 1433 |
-
|
| 1434 |
-
// ⭐ OrbitControls target
|
| 1435 |
-
cameraControls.controls.target.set(0, 0, 0);
|
| 1436 |
-
cameraControls.controls.update();
|
| 1437 |
-
console.log('[preprocessManual] OrbitControls target set to (0, 0, 0)');
|
| 1438 |
-
|
| 1439 |
-
// ========================================
|
| 1440 |
-
// Box Setup (centered at origin)
|
| 1441 |
-
// ========================================
|
| 1442 |
-
let boxSize = {
|
| 1443 |
-
x: size.x * 1.2, // 120% of PLY size
|
| 1444 |
-
y: size.y * 1.2,
|
| 1445 |
-
z: size.z * 1.2
|
| 1446 |
-
};
|
| 1447 |
-
|
| 1448 |
-
let boxPosition = { x: 0, y: 0, z: 0 }; // Always at origin
|
| 1449 |
-
let boxRotation = { x: 0, y: 0, z: 0 };
|
| 1450 |
-
let plyOffset = { x: 0, y: 0, z: 0 };
|
| 1451 |
-
|
| 1452 |
-
console.log('[preprocessManual] Initial Box setup:');
|
| 1453 |
-
console.log(' boxSize:', boxSize);
|
| 1454 |
-
console.log(' boxPosition:', boxPosition, '(origin)');
|
| 1455 |
-
|
| 1456 |
-
|
| 1457 |
-
////////////////END1137
|
| 1458 |
const sceneCenter = {
|
| 1459 |
x: (maxX + minX) / 2,
|
| 1460 |
y: (maxY + minY) / 2,
|
|
|
|
| 1351 |
// ========================================
|
| 1352 |
|
| 1353 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1354 |
const sceneCenter = {
|
| 1355 |
x: (maxX + minX) / 2,
|
| 1356 |
y: (maxY + minY) / 2,
|