Upload preprocess_manual.js
Browse files- preprocess_manual.js +0 -149
preprocess_manual.js
CHANGED
|
@@ -2334,11 +2334,6 @@ function setupBoneAssignment(ui, scene, camera, renderer, gvrm, character, filte
|
|
| 2334 |
};
|
| 2335 |
|
| 2336 |
|
| 2337 |
-
|
| 2338 |
-
|
| 2339 |
-
|
| 2340 |
-
|
| 2341 |
-
|
| 2342 |
function updateBoneSelector(mode) {
|
| 2343 |
if (!boneSelector) {
|
| 2344 |
console.error('[updateBoneSelector] boneSelector not found');
|
|
@@ -2430,70 +2425,6 @@ function setupBoneAssignment(ui, scene, camera, renderer, gvrm, character, filte
|
|
| 2430 |
const raycaster = new THREE.Raycaster();
|
| 2431 |
const mouse = new THREE.Vector2();
|
| 2432 |
|
| 2433 |
-
/**
|
| 2434 |
-
* 2D画面座標から最も近い3D Splatを検索
|
| 2435 |
-
*/
|
| 2436 |
-
function findNearestSplat(mouseX, mouseY, camera, filteredGs, maxScreenDistance = 100) {
|
| 2437 |
-
console.log('[findNearestSplat] Searching for splat near mouse:', { mouseX, mouseY });
|
| 2438 |
-
|
| 2439 |
-
const canvas = renderer.domElement;
|
| 2440 |
-
const mousePixelX = (mouseX + 1) * canvas.width / 2;
|
| 2441 |
-
const mousePixelY = (-mouseY + 1) * canvas.height / 2;
|
| 2442 |
-
|
| 2443 |
-
let nearestSplatIndex = -1;
|
| 2444 |
-
let nearestScreenDist = Infinity;
|
| 2445 |
-
let nearestWorldDist = Infinity;
|
| 2446 |
-
|
| 2447 |
-
const cameraPos = camera.position;
|
| 2448 |
-
const worldPos = new THREE.Vector3();
|
| 2449 |
-
const screenPos = new THREE.Vector3();
|
| 2450 |
-
|
| 2451 |
-
for (let i = 0; i < filteredGs.splatCount; i++) {
|
| 2452 |
-
worldPos.x = filteredGs.centers0[i * 3 + 0];
|
| 2453 |
-
worldPos.y = filteredGs.centers0[i * 3 + 1];
|
| 2454 |
-
worldPos.z = filteredGs.centers0[i * 3 + 2];
|
| 2455 |
-
|
| 2456 |
-
screenPos.copy(worldPos);
|
| 2457 |
-
screenPos.project(camera);
|
| 2458 |
-
|
| 2459 |
-
if (screenPos.z > 1) continue;
|
| 2460 |
-
|
| 2461 |
-
const screenPixelX = (screenPos.x + 1) * canvas.width / 2;
|
| 2462 |
-
const screenPixelY = (-screenPos.y + 1) * canvas.height / 2;
|
| 2463 |
-
|
| 2464 |
-
const dx = screenPixelX - mousePixelX;
|
| 2465 |
-
const dy = screenPixelY - mousePixelY;
|
| 2466 |
-
const screenDist = Math.sqrt(dx * dx + dy * dy);
|
| 2467 |
-
|
| 2468 |
-
if (screenDist < maxScreenDistance && screenDist < nearestScreenDist) {
|
| 2469 |
-
nearestScreenDist = screenDist;
|
| 2470 |
-
nearestSplatIndex = i;
|
| 2471 |
-
|
| 2472 |
-
const worldDx = worldPos.x - cameraPos.x;
|
| 2473 |
-
const worldDy = worldPos.y - cameraPos.y;
|
| 2474 |
-
const worldDz = worldPos.z - cameraPos.z;
|
| 2475 |
-
nearestWorldDist = Math.sqrt(worldDx * worldDx + worldDy * worldDy + worldDz * worldDz);
|
| 2476 |
-
}
|
| 2477 |
-
}
|
| 2478 |
-
|
| 2479 |
-
if (nearestSplatIndex >= 0) {
|
| 2480 |
-
console.log('[findNearestSplat] ✓ Found nearest splat:', {
|
| 2481 |
-
index: nearestSplatIndex,
|
| 2482 |
-
screenDistance: nearestScreenDist.toFixed(1) + 'px',
|
| 2483 |
-
worldDistance: nearestWorldDist.toFixed(3) + 'm'
|
| 2484 |
-
});
|
| 2485 |
-
|
| 2486 |
-
return {
|
| 2487 |
-
index: nearestSplatIndex,
|
| 2488 |
-
screenDistance: nearestScreenDist,
|
| 2489 |
-
worldDistance: nearestWorldDist
|
| 2490 |
-
};
|
| 2491 |
-
}
|
| 2492 |
-
|
| 2493 |
-
console.log('[findNearestSplat] ✗ No splat found within', maxScreenDistance, 'px');
|
| 2494 |
-
return null;
|
| 2495 |
-
}
|
| 2496 |
-
|
| 2497 |
/**
|
| 2498 |
* 球体範囲内の全Splatを検索
|
| 2499 |
*/
|
|
@@ -2520,64 +2451,6 @@ function findSplatsInSphere(center, radius, filteredGs) {
|
|
| 2520 |
return indicesInSphere;
|
| 2521 |
}
|
| 2522 |
|
| 2523 |
-
/**
|
| 2524 |
-
* ペイントモード用: マウスパスに沿ってSplatを塗る
|
| 2525 |
-
*/
|
| 2526 |
-
function findSplatsAlongMousePath(mouseX, mouseY, lastMouseX, lastMouseY, camera, filteredGs, brushRadius = 30) {
|
| 2527 |
-
const affectedSplats = new Set();
|
| 2528 |
-
|
| 2529 |
-
const steps = 5;
|
| 2530 |
-
for (let step = 0; step <= steps; step++) {
|
| 2531 |
-
const t = step / steps;
|
| 2532 |
-
const interpX = lastMouseX + (mouseX - lastMouseX) * t;
|
| 2533 |
-
const interpY = lastMouseY + (mouseY - lastMouseY) * t;
|
| 2534 |
-
|
| 2535 |
-
const result = findNearestSplatWithRadius(interpX, interpY, camera, filteredGs, brushRadius);
|
| 2536 |
-
if (result && result.indices) {
|
| 2537 |
-
result.indices.forEach(idx => affectedSplats.add(idx));
|
| 2538 |
-
}
|
| 2539 |
-
}
|
| 2540 |
-
|
| 2541 |
-
return Array.from(affectedSplats);
|
| 2542 |
-
}
|
| 2543 |
-
|
| 2544 |
-
/**
|
| 2545 |
-
* ブラシ半径内の全Splatを返す
|
| 2546 |
-
*/
|
| 2547 |
-
function findNearestSplatWithRadius(mouseX, mouseY, camera, filteredGs, brushRadius) {
|
| 2548 |
-
const canvas = renderer.domElement;
|
| 2549 |
-
const mousePixelX = (mouseX + 1) * canvas.width / 2;
|
| 2550 |
-
const mousePixelY = (-mouseY + 1) * canvas.height / 2;
|
| 2551 |
-
|
| 2552 |
-
const affectedIndices = [];
|
| 2553 |
-
const worldPos = new THREE.Vector3();
|
| 2554 |
-
const screenPos = new THREE.Vector3();
|
| 2555 |
-
|
| 2556 |
-
for (let i = 0; i < filteredGs.splatCount; i++) {
|
| 2557 |
-
worldPos.x = filteredGs.centers0[i * 3 + 0];
|
| 2558 |
-
worldPos.y = filteredGs.centers0[i * 3 + 1];
|
| 2559 |
-
worldPos.z = filteredGs.centers0[i * 3 + 2];
|
| 2560 |
-
|
| 2561 |
-
screenPos.copy(worldPos);
|
| 2562 |
-
screenPos.project(camera);
|
| 2563 |
-
|
| 2564 |
-
if (screenPos.z > 1) continue;
|
| 2565 |
-
|
| 2566 |
-
const screenPixelX = (screenPos.x + 1) * canvas.width / 2;
|
| 2567 |
-
const screenPixelY = (-screenPos.y + 1) * canvas.height / 2;
|
| 2568 |
-
|
| 2569 |
-
const dx = screenPixelX - mousePixelX;
|
| 2570 |
-
const dy = screenPixelY - mousePixelY;
|
| 2571 |
-
const screenDist = Math.sqrt(dx * dx + dy * dy);
|
| 2572 |
-
|
| 2573 |
-
if (screenDist < brushRadius) {
|
| 2574 |
-
affectedIndices.push(i);
|
| 2575 |
-
}
|
| 2576 |
-
}
|
| 2577 |
-
|
| 2578 |
-
return affectedIndices.length > 0 ? { indices: affectedIndices } : null;
|
| 2579 |
-
}
|
| 2580 |
-
|
| 2581 |
// ========================================
|
| 2582 |
// マウスイベント処理
|
| 2583 |
// ========================================
|
|
@@ -2874,28 +2747,6 @@ function findNearestSplat(mouseX, mouseY, camera, filteredGs, maxScreenDistance
|
|
| 2874 |
* @param {Object} filteredGs - Gaussian Splat データ
|
| 2875 |
* @returns {Array<number>} Splat インデックスの配列
|
| 2876 |
*/
|
| 2877 |
-
function findSplatsInSphere(center, radius, filteredGs) {
|
| 2878 |
-
const indicesInSphere = [];
|
| 2879 |
-
const radiusSquared = radius * radius;
|
| 2880 |
-
|
| 2881 |
-
for (let i = 0; i < filteredGs.splatCount; i++) {
|
| 2882 |
-
const x = filteredGs.centers0[i * 3 + 0];
|
| 2883 |
-
const y = filteredGs.centers0[i * 3 + 1];
|
| 2884 |
-
const z = filteredGs.centers0[i * 3 + 2];
|
| 2885 |
-
|
| 2886 |
-
const dx = x - center.x;
|
| 2887 |
-
const dy = y - center.y;
|
| 2888 |
-
const dz = z - center.z;
|
| 2889 |
-
const distSquared = dx * dx + dy * dy + dz * dz;
|
| 2890 |
-
|
| 2891 |
-
if (distSquared <= radiusSquared) {
|
| 2892 |
-
indicesInSphere.push(i);
|
| 2893 |
-
}
|
| 2894 |
-
}
|
| 2895 |
-
|
| 2896 |
-
console.log('[findSplatsInSphere] Found', indicesInSphere.length, 'splats within radius', radius.toFixed(2), 'm');
|
| 2897 |
-
return indicesInSphere;
|
| 2898 |
-
}
|
| 2899 |
|
| 2900 |
/**
|
| 2901 |
* ペイントモード用: マウスパスに沿ってSplatを塗る
|
|
|
|
| 2334 |
};
|
| 2335 |
|
| 2336 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2337 |
function updateBoneSelector(mode) {
|
| 2338 |
if (!boneSelector) {
|
| 2339 |
console.error('[updateBoneSelector] boneSelector not found');
|
|
|
|
| 2425 |
const raycaster = new THREE.Raycaster();
|
| 2426 |
const mouse = new THREE.Vector2();
|
| 2427 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2428 |
/**
|
| 2429 |
* 球体範囲内の全Splatを検索
|
| 2430 |
*/
|
|
|
|
| 2451 |
return indicesInSphere;
|
| 2452 |
}
|
| 2453 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2454 |
// ========================================
|
| 2455 |
// マウスイベント処理
|
| 2456 |
// ========================================
|
|
|
|
| 2747 |
* @param {Object} filteredGs - Gaussian Splat データ
|
| 2748 |
* @returns {Array<number>} Splat インデックスの配列
|
| 2749 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2750 |
|
| 2751 |
/**
|
| 2752 |
* ペイントモード用: マウスパスに沿ってSplatを塗る
|