Upload preprocess_manual.js
Browse files- preprocess_manual.js +100 -93
preprocess_manual.js
CHANGED
|
@@ -1464,8 +1464,9 @@ if (confirmBoxBtn) {
|
|
| 1464 |
|
| 1465 |
///// Line 1113-1419 ใไปฅไธใซ็ฝฎใๆใ ///// Line 1113-1419 ใไปฅไธใซ็ฝฎใๆใ
|
| 1466 |
|
| 1467 |
-
|
| 1468 |
-
|
|
|
|
| 1469 |
GVRM.initGS(gsPath, undefined, undefined, scene).then((gs) => {
|
| 1470 |
console.log('[preprocessManual] GS initialized');
|
| 1471 |
|
|
@@ -1490,10 +1491,14 @@ if (confirmBoxBtn) {
|
|
| 1490 |
}
|
| 1491 |
|
| 1492 |
// ========================================
|
| 1493 |
-
// โญ 1.
|
| 1494 |
// ========================================
|
| 1495 |
-
|
| 1496 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1497 |
|
| 1498 |
// ========================================
|
| 1499 |
// โญ 2. ใญใผใใผใใณใณใใญใผใซใๅๆๅ
|
|
@@ -1503,9 +1508,9 @@ if (confirmBoxBtn) {
|
|
| 1503 |
|
| 1504 |
// ========================================
|
| 1505 |
// โญ 3. ใขใใกใผใทใงใณใซใผใใ้ๅง
|
| 1506 |
-
// ========================================
|
| 1507 |
-
|
| 1508 |
-
//
|
| 1509 |
if (!window.cameraLockState) {
|
| 1510 |
window.cameraLockState = {
|
| 1511 |
locked: false,
|
|
@@ -1521,18 +1526,18 @@ if (confirmBoxBtn) {
|
|
| 1521 |
|
| 1522 |
// ใญใผใใผใใณใณใใญใผใซใฎๆดๆฐ๏ผใซใกใฉใญใใฏๆใฏ็กๅนๅ๏ผ
|
| 1523 |
if (!window.cameraLockState.locked) {
|
| 1524 |
-
updateCameraFromKeys(camera,
|
| 1525 |
}
|
| 1526 |
|
| 1527 |
// โญโญโญ ้่ฆ๏ผใซใกใฉใใญใใฏใใใฆใใๅ ดๅใฏOrbitControlsใๅผทๅถ็ใซ็กๅนๅใ็ถใใ
|
| 1528 |
if (window.cameraLockState.locked) {
|
| 1529 |
-
if (
|
| 1530 |
-
|
| 1531 |
}
|
| 1532 |
} else {
|
| 1533 |
// ใซใกใฉใใขใณใญใใฏใใใฆใใๅ ดๅใฎใฟๆดๆฐ
|
| 1534 |
-
if (
|
| 1535 |
-
|
| 1536 |
}
|
| 1537 |
}
|
| 1538 |
|
|
@@ -1540,7 +1545,7 @@ if (confirmBoxBtn) {
|
|
| 1540 |
if (window.cameraLockState.frameCount % 600 === 0) {
|
| 1541 |
console.log('[animateControls] Status check:', {
|
| 1542 |
locked: window.cameraLockState.locked,
|
| 1543 |
-
controlsEnabled:
|
| 1544 |
frame: window.cameraLockState.frameCount
|
| 1545 |
});
|
| 1546 |
}
|
|
@@ -1551,6 +1556,7 @@ if (confirmBoxBtn) {
|
|
| 1551 |
animateControls();
|
| 1552 |
console.log('[preprocessManual] โ Animation loop started with camera lock support');
|
| 1553 |
|
|
|
|
| 1554 |
|
| 1555 |
// Cleanup function to stop animation
|
| 1556 |
const cleanupAnimation = () => {
|
|
@@ -1597,15 +1603,17 @@ if (confirmBoxBtn) {
|
|
| 1597 |
camera.position.set(0, maxDim * 0.3, distance);
|
| 1598 |
camera.lookAt(0, 0, 0);
|
| 1599 |
camera.updateProjectionMatrix();
|
| 1600 |
-
|
| 1601 |
-
|
| 1602 |
-
|
| 1603 |
|
| 1604 |
console.log('[preprocessManual] Camera positioned at:', {
|
| 1605 |
x: camera.position.x.toFixed(2),
|
| 1606 |
y: camera.position.y.toFixed(2),
|
| 1607 |
z: camera.position.z.toFixed(2)
|
| 1608 |
});
|
|
|
|
|
|
|
| 1609 |
console.log('[preprocessManual] Initial box setup - size:', boxSize);
|
| 1610 |
|
| 1611 |
|
|
@@ -2476,92 +2484,91 @@ function setupBoneAssignment(ui, scene, camera, renderer, gvrm, character, filte
|
|
| 2476 |
// ========================================
|
| 2477 |
// Camera Lock Setup (ๅฎๅ
จ็)
|
| 2478 |
// ========================================
|
| 2479 |
-
|
| 2480 |
|
| 2481 |
-
// ใใฟใณใๅๅพ
|
| 2482 |
-
const cameraLockBtn = document.getElementById('camera-lock-btn');
|
| 2483 |
|
| 2484 |
-
|
| 2485 |
-
|
| 2486 |
-
|
| 2487 |
-
|
| 2488 |
-
|
| 2489 |
-
|
| 2490 |
-
|
| 2491 |
-
|
| 2492 |
-
|
| 2493 |
-
|
| 2494 |
-
|
| 2495 |
-
|
| 2496 |
-
|
| 2497 |
-
|
| 2498 |
-
|
| 2499 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2500 |
|
| 2501 |
-
|
| 2502 |
-
|
| 2503 |
-
|
| 2504 |
-
|
| 2505 |
-
// OrbitControlsใ็กๅนๅ
|
| 2506 |
-
if (cameraControls && cameraControls.controls) {
|
| 2507 |
-
cameraControls.controls.enabled = false;
|
| 2508 |
-
console.log(' โ OrbitControls.enabled = false');
|
| 2509 |
-
} else {
|
| 2510 |
-
console.warn(' โ ๏ธ cameraControls not available!');
|
| 2511 |
-
}
|
| 2512 |
-
|
| 2513 |
-
// UIใๆดๆฐ
|
| 2514 |
-
cameraLockBtn.textContent = '๐ Camera Locked (Fixed View)';
|
| 2515 |
-
cameraLockBtn.style.background = '#E91E63';
|
| 2516 |
-
cameraLockBtn.style.fontWeight = 'bold';
|
| 2517 |
-
|
| 2518 |
-
console.log('โ
Camera locked');
|
| 2519 |
-
console.log('โน๏ธ Try to rotate the camera with mouse - it should NOT move');
|
| 2520 |
-
console.log('โน๏ธ You can still click to paint');
|
| 2521 |
-
|
| 2522 |
-
} else {
|
| 2523 |
-
// === ใซใกใฉใฎใญใใฏใ่งฃ้ค ===
|
| 2524 |
-
console.log('Unlocking camera...');
|
| 2525 |
-
|
| 2526 |
-
// OrbitControlsใๆๅนๅ
|
| 2527 |
-
if (cameraControls && cameraControls.controls) {
|
| 2528 |
-
cameraControls.controls.enabled = true;
|
| 2529 |
-
console.log(' โ OrbitControls.enabled = true');
|
| 2530 |
-
} else {
|
| 2531 |
-
console.warn(' โ ๏ธ cameraControls not available!');
|
| 2532 |
-
}
|
| 2533 |
-
|
| 2534 |
-
// UIใๆดๆฐ
|
| 2535 |
-
cameraLockBtn.textContent = '๐ Camera Unlocked (Can Rotate)';
|
| 2536 |
-
cameraLockBtn.style.background = '#9C27B0';
|
| 2537 |
-
cameraLockBtn.style.fontWeight = 'bold';
|
| 2538 |
-
|
| 2539 |
-
console.log('โ
Camera unlocked');
|
| 2540 |
-
console.log('โน๏ธ Camera can now be rotated with mouse');
|
| 2541 |
}
|
| 2542 |
|
| 2543 |
-
//
|
| 2544 |
-
|
| 2545 |
-
|
| 2546 |
-
|
| 2547 |
-
console.log('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2548 |
if (cameraControls && cameraControls.controls) {
|
| 2549 |
-
|
|
|
|
| 2550 |
}
|
| 2551 |
-
|
| 2552 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2553 |
}
|
| 2554 |
|
| 2555 |
-
//
|
| 2556 |
-
|
| 2557 |
-
|
| 2558 |
-
|
| 2559 |
-
|
| 2560 |
-
|
| 2561 |
-
|
| 2562 |
-
|
| 2563 |
-
console.log('
|
|
|
|
|
|
|
| 2564 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2565 |
|
| 2566 |
|
| 2567 |
// Call this after OrbitControls is created
|
|
|
|
| 1464 |
|
| 1465 |
///// Line 1113-1419 ใไปฅไธใซ็ฝฎใๆใ ///// Line 1113-1419 ใไปฅไธใซ็ฝฎใๆใ
|
| 1466 |
|
| 1467 |
+
|
| 1468 |
+
/////////////////////////////ใใใใ
|
| 1469 |
+
|
| 1470 |
GVRM.initGS(gsPath, undefined, undefined, scene).then((gs) => {
|
| 1471 |
console.log('[preprocessManual] GS initialized');
|
| 1472 |
|
|
|
|
| 1491 |
}
|
| 1492 |
|
| 1493 |
// ========================================
|
| 1494 |
+
// โญ 1. ใซใกใฉใณใณใใญใผใซใๅๆๅ๏ผใฐใญใผใใซใซไฟๅญ๏ผ
|
| 1495 |
// ========================================
|
| 1496 |
+
if (!window.globalCameraControls) {
|
| 1497 |
+
window.globalCameraControls = setupCameraControls(camera, renderer);
|
| 1498 |
+
console.log('[preprocessManual] โ Camera controls created and saved globally');
|
| 1499 |
+
} else {
|
| 1500 |
+
console.log('[preprocessManual] Using existing global camera controls');
|
| 1501 |
+
}
|
| 1502 |
|
| 1503 |
// ========================================
|
| 1504 |
// โญ 2. ใญใผใใผใใณใณใใญใผใซใๅๆๅ
|
|
|
|
| 1508 |
|
| 1509 |
// ========================================
|
| 1510 |
// โญ 3. ใขใใกใผใทใงใณใซใผใใ้ๅง
|
| 1511 |
+
// ========================================
|
| 1512 |
+
|
| 1513 |
+
// ใฐใญใผใใซใชใซใกใฉใญใใฏ็ถๆ
|
| 1514 |
if (!window.cameraLockState) {
|
| 1515 |
window.cameraLockState = {
|
| 1516 |
locked: false,
|
|
|
|
| 1526 |
|
| 1527 |
// ใญใผใใผใใณใณใใญใผใซใฎๆดๆฐ๏ผใซใกใฉใญใใฏๆใฏ็กๅนๅ๏ผ
|
| 1528 |
if (!window.cameraLockState.locked) {
|
| 1529 |
+
updateCameraFromKeys(camera, window.globalCameraControls);
|
| 1530 |
}
|
| 1531 |
|
| 1532 |
// โญโญโญ ้่ฆ๏ผใซใกใฉใใญใใฏใใใฆใใๅ ดๅใฏOrbitControlsใๅผทๅถ็ใซ็กๅนๅใ็ถใใ
|
| 1533 |
if (window.cameraLockState.locked) {
|
| 1534 |
+
if (window.globalCameraControls && window.globalCameraControls.controls) {
|
| 1535 |
+
window.globalCameraControls.controls.enabled = false;
|
| 1536 |
}
|
| 1537 |
} else {
|
| 1538 |
// ใซใกใฉใใขใณใญใใฏใใใฆใใๅ ดๅใฎใฟๆดๆฐ
|
| 1539 |
+
if (window.globalCameraControls && window.globalCameraControls.controls) {
|
| 1540 |
+
window.globalCameraControls.controls.update();
|
| 1541 |
}
|
| 1542 |
}
|
| 1543 |
|
|
|
|
| 1545 |
if (window.cameraLockState.frameCount % 600 === 0) {
|
| 1546 |
console.log('[animateControls] Status check:', {
|
| 1547 |
locked: window.cameraLockState.locked,
|
| 1548 |
+
controlsEnabled: window.globalCameraControls?.controls?.enabled,
|
| 1549 |
frame: window.cameraLockState.frameCount
|
| 1550 |
});
|
| 1551 |
}
|
|
|
|
| 1556 |
animateControls();
|
| 1557 |
console.log('[preprocessManual] โ Animation loop started with camera lock support');
|
| 1558 |
|
| 1559 |
+
////ใใใพใง
|
| 1560 |
|
| 1561 |
// Cleanup function to stop animation
|
| 1562 |
const cleanupAnimation = () => {
|
|
|
|
| 1603 |
camera.position.set(0, maxDim * 0.3, distance);
|
| 1604 |
camera.lookAt(0, 0, 0);
|
| 1605 |
camera.updateProjectionMatrix();
|
| 1606 |
+
////
|
| 1607 |
+
window.globalCameraControls.controls.target.set(0, 0, 0);
|
| 1608 |
+
window.globalCameraControls.controls.update();
|
| 1609 |
|
| 1610 |
console.log('[preprocessManual] Camera positioned at:', {
|
| 1611 |
x: camera.position.x.toFixed(2),
|
| 1612 |
y: camera.position.y.toFixed(2),
|
| 1613 |
z: camera.position.z.toFixed(2)
|
| 1614 |
});
|
| 1615 |
+
////
|
| 1616 |
+
|
| 1617 |
console.log('[preprocessManual] Initial box setup - size:', boxSize);
|
| 1618 |
|
| 1619 |
|
|
|
|
| 2484 |
// ========================================
|
| 2485 |
// Camera Lock Setup (ๅฎๅ
จ็)
|
| 2486 |
// ========================================
|
| 2487 |
+
/////ใใใใ
|
| 2488 |
|
|
|
|
|
|
|
| 2489 |
|
| 2490 |
+
// ========================================
|
| 2491 |
+
// Camera Lock Setup ใฎไฟฎๆญฃ็
|
| 2492 |
+
// Line 2479-2562 ไป่ฟใไปฅไธใซ็ฝฎใๆใใฆใใ ใใ
|
| 2493 |
+
// ========================================
|
| 2494 |
+
|
| 2495 |
+
console.log('[setupBoneAssignment] Setting up camera lock...');
|
| 2496 |
+
|
| 2497 |
+
const cameraLockBtn = document.getElementById('camera-lock-btn');
|
| 2498 |
+
|
| 2499 |
+
if (!cameraLockBtn) {
|
| 2500 |
+
console.error('[setupBoneAssignment] โ Camera lock button NOT FOUND!');
|
| 2501 |
+
} else {
|
| 2502 |
+
console.log('[setupBoneAssignment] โ Camera lock button found');
|
| 2503 |
+
|
| 2504 |
+
// ใซใกใฉใญใใฏๅใๆฟใ้ขๆฐ
|
| 2505 |
+
function toggleCameraLock() {
|
| 2506 |
+
// ใฐใญใผใใซ็ถๆ
ใๅ่ปข
|
| 2507 |
+
window.cameraLockState.locked = !window.cameraLockState.locked;
|
| 2508 |
+
const isLocked = window.cameraLockState.locked;
|
| 2509 |
+
|
| 2510 |
+
console.log('');
|
| 2511 |
+
console.log('โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ');
|
| 2512 |
+
console.log(' CAMERA LOCK TOGGLE');
|
| 2513 |
+
console.log('โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ');
|
| 2514 |
+
console.log('New state:', isLocked ? '๐ LOCKED' : '๐ UNLOCKED');
|
| 2515 |
+
|
| 2516 |
+
if (isLocked) {
|
| 2517 |
+
console.log('Locking camera...');
|
| 2518 |
|
| 2519 |
+
// OrbitControlsใ็กๅนๅ
|
| 2520 |
+
if (cameraControls && cameraControls.controls) {
|
| 2521 |
+
cameraControls.controls.enabled = false;
|
| 2522 |
+
console.log(' โ OrbitControls.enabled = false');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2523 |
}
|
| 2524 |
|
| 2525 |
+
// โญโญโญ ใใฟใณใฎใใญในใใจในใฟใคใซใ๏ฟฝ๏ฟฝๆฐ โญโญโญ
|
| 2526 |
+
cameraLockBtn.textContent = '๐ Camera Locked (Click to Unlock)';
|
| 2527 |
+
cameraLockBtn.style.background = '#4CAF50'; // ็ท่ฒใซๅคๆด
|
| 2528 |
+
|
| 2529 |
+
console.log('โ
Camera locked');
|
| 2530 |
+
console.log('โน๏ธ Try to rotate the camera with mouse - it should NOT move');
|
| 2531 |
+
console.log('โน๏ธ You can still click to paint');
|
| 2532 |
+
|
| 2533 |
+
} else {
|
| 2534 |
+
console.log('Unlocking camera...');
|
| 2535 |
+
|
| 2536 |
+
// OrbitControlsใๆๅนๅ
|
| 2537 |
if (cameraControls && cameraControls.controls) {
|
| 2538 |
+
cameraControls.controls.enabled = true;
|
| 2539 |
+
console.log(' โ OrbitControls.enabled = true');
|
| 2540 |
}
|
| 2541 |
+
|
| 2542 |
+
// โญโญโญ ใใฟใณใฎใใญในใใจในใฟใคใซใๆดๆฐ โญโญโญ
|
| 2543 |
+
cameraLockBtn.textContent = '๐ Camera Unlocked (Can Rotate)';
|
| 2544 |
+
cameraLockBtn.style.background = '#9C27B0'; // ๅ
ใฎ็ดซ่ฒใซๆปใ
|
| 2545 |
+
|
| 2546 |
+
console.log('โ
Camera unlocked');
|
| 2547 |
+
console.log('โน๏ธ Camera can now be rotated with mouse');
|
| 2548 |
}
|
| 2549 |
|
| 2550 |
+
// ใใใใฐๆ
ๅ ฑใๅบๅ
|
| 2551 |
+
console.log('โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ');
|
| 2552 |
+
console.log('Current state:');
|
| 2553 |
+
console.log(' window.cameraLockState.locked:', window.cameraLockState.locked);
|
| 2554 |
+
console.log(' cameraControls exists:', !!cameraControls);
|
| 2555 |
+
if (cameraControls && cameraControls.controls) {
|
| 2556 |
+
console.log(' cameraControls.controls.enabled:', cameraControls.controls.enabled);
|
| 2557 |
+
}
|
| 2558 |
+
console.log(' Button text:', cameraLockBtn.textContent);
|
| 2559 |
+
console.log('โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ');
|
| 2560 |
+
console.log('');
|
| 2561 |
}
|
| 2562 |
+
|
| 2563 |
+
// โ
ใใฟใณใฎใฏใชใใฏใคใใณใใ่จญๅฎ
|
| 2564 |
+
cameraLockBtn.addEventListener('click', toggleCameraLock);
|
| 2565 |
+
|
| 2566 |
+
console.log('[setupBoneAssignment] โ Camera lock button configured');
|
| 2567 |
+
console.log('[setupBoneAssignment] Initial state: UNLOCKED');
|
| 2568 |
+
}
|
| 2569 |
+
|
| 2570 |
+
////ใใใพใง
|
| 2571 |
+
|
| 2572 |
|
| 2573 |
|
| 2574 |
// Call this after OrbitControls is created
|