Upload preprocess_manual.js
Browse files- preprocess_manual.js +171 -171
preprocess_manual.js
CHANGED
|
@@ -529,92 +529,98 @@ function createFilteredPLY(parser, originalHeader, filteredVertices, vertexSize)
|
|
| 529 |
return URL.createObjectURL(blob);
|
| 530 |
}
|
| 531 |
|
| 532 |
-
|
| 533 |
-
* Manual preprocessing - メイン関数
|
| 534 |
-
*/
|
| 535 |
-
|
| 536 |
-
export function preprocessManual(vrmPath, gsPath, scene, camera, renderer, stage, useGPU, noBG, noCheck, fileName, savePly) {
|
| 537 |
-
console.log('[preprocessManual] ===== FUNCTION CALLED =====');
|
| 538 |
-
console.log('[preprocessManual] Parameters:');
|
| 539 |
-
console.log(' vrmPath:', vrmPath);
|
| 540 |
-
console.log(' gsPath:', gsPath);
|
| 541 |
-
console.log(' fileName:', fileName);
|
| 542 |
-
|
| 543 |
-
return new Promise((resolve, reject) => {
|
| 544 |
-
console.log('[preprocessManual] Creating Promise...');
|
| 545 |
-
|
| 546 |
-
try {
|
| 547 |
-
const ui = createManualUI(scene, camera, renderer);
|
| 548 |
-
console.log('[preprocessManual] UI created');
|
| 549 |
-
|
| 550 |
-
ui.initialize().then(() => {
|
| 551 |
-
console.log('[preprocessManual] UI initialized, starting manual process...');
|
| 552 |
-
|
| 553 |
-
ui.show();
|
| 554 |
-
ui.setStatus('Loading PLY file...');
|
| 555 |
-
|
| 556 |
-
// PLYファイルの読み込み
|
| 557 |
-
const parser = new PLYParser();
|
| 558 |
-
let loadingSpinner = new DropInViewer().viewer.loadingSpinner;
|
| 559 |
-
const task = loadingSpinner.addTask('Loading PLY...');
|
| 560 |
-
|
| 561 |
-
parser.parsePLY(gsPath, true).then((plyData) => {
|
| 562 |
-
console.log('[preprocessManual] PLY loaded:', plyData.vertices.length, 'vertices');
|
| 563 |
-
loadingSpinner.removeTask(task);
|
| 564 |
-
|
| 565 |
-
// GSの初期表示, replace all 20251207
|
| 566 |
-
GVRM.initGS(gsPath, undefined, undefined, scene).then((gs) => {
|
| 567 |
-
console.log('[preprocessManual] GS initialized');
|
| 568 |
-
|
| 569 |
-
// ★★★ ADD CAMERA CONTROLS HERE ★★★
|
| 570 |
-
const cameraControls = setupCameraControls(camera, renderer);
|
| 571 |
-
|
| 572 |
-
// Animation loop for smooth camera controls
|
| 573 |
-
let animationId = null;
|
| 574 |
-
function animateControls() {
|
| 575 |
-
animationId = requestAnimationFrame(animateControls);
|
| 576 |
-
updateCameraFromKeys(); // ⭐ この行を追加
|
| 577 |
-
cameraControls.controls.update();
|
| 578 |
-
renderer.render(scene, camera);
|
| 579 |
-
}
|
| 580 |
-
|
| 581 |
-
animateControls();
|
| 582 |
-
|
| 583 |
-
// Cleanup function to stop animation
|
| 584 |
-
const cleanupAnimation = () => {
|
| 585 |
-
if (animationId) {
|
| 586 |
-
cancelAnimationFrame(animationId);
|
| 587 |
-
animationId = null;
|
| 588 |
-
}
|
| 589 |
-
};
|
| 590 |
-
|
| 591 |
-
////////////////handle key 1213 13:30
|
| 592 |
|
| 593 |
// ========================================
|
| 594 |
-
// Keyboard Controls
|
| 595 |
// ========================================
|
| 596 |
let activeKeys = [];
|
| 597 |
|
| 598 |
-
//
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 604 |
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 608 |
|
| 609 |
-
|
| 610 |
-
|
| 611 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 612 |
|
| 613 |
-
// Camera manipulation function
|
| 614 |
-
function updateCameraFromKeys() {
|
| 615 |
if (activeKeys.length === 0) return;
|
| 616 |
|
| 617 |
-
// Get current camera matrix
|
| 618 |
let inv = invert4(camera.matrixWorld.elements);
|
| 619 |
if (!inv) return;
|
| 620 |
|
|
@@ -623,58 +629,46 @@ export function preprocessManual(vrmPath, gsPath, scene, camera, renderer, stage
|
|
| 623 |
// Movement (arrow keys)
|
| 624 |
if (activeKeys.includes("ArrowUp")) {
|
| 625 |
if (shiftKey) {
|
| 626 |
-
// Move up (Y axis)
|
| 627 |
inv = translate4(inv, 0, -0.03, 0);
|
| 628 |
} else {
|
| 629 |
-
// Move forward (Z axis)
|
| 630 |
inv = translate4(inv, 0, 0, 0.1);
|
| 631 |
}
|
| 632 |
}
|
| 633 |
if (activeKeys.includes("ArrowDown")) {
|
| 634 |
if (shiftKey) {
|
| 635 |
-
// Move down (Y axis)
|
| 636 |
inv = translate4(inv, 0, 0.03, 0);
|
| 637 |
} else {
|
| 638 |
-
// Move backward (Z axis)
|
| 639 |
inv = translate4(inv, 0, 0, -0.1);
|
| 640 |
}
|
| 641 |
}
|
| 642 |
if (activeKeys.includes("ArrowLeft")) {
|
| 643 |
-
// Strafe left (X axis)
|
| 644 |
inv = translate4(inv, -0.03, 0, 0);
|
| 645 |
}
|
| 646 |
if (activeKeys.includes("ArrowRight")) {
|
| 647 |
-
// Strafe right (X axis)
|
| 648 |
inv = translate4(inv, 0.03, 0, 0);
|
| 649 |
}
|
| 650 |
|
| 651 |
-
// Camera angle (WASD
|
| 652 |
if (activeKeys.includes("KeyA")) {
|
| 653 |
-
// Turn left (Y axis rotation)
|
| 654 |
inv = rotate4(inv, -0.01, 0, 1, 0);
|
| 655 |
}
|
| 656 |
if (activeKeys.includes("KeyD")) {
|
| 657 |
-
// Turn right (Y axis rotation)
|
| 658 |
inv = rotate4(inv, 0.01, 0, 1, 0);
|
| 659 |
}
|
| 660 |
if (activeKeys.includes("KeyW")) {
|
| 661 |
-
// Tilt up (X axis rotation)
|
| 662 |
inv = rotate4(inv, 0.005, 1, 0, 0);
|
| 663 |
}
|
| 664 |
if (activeKeys.includes("KeyS")) {
|
| 665 |
-
// Tilt down (X axis rotation)
|
| 666 |
inv = rotate4(inv, -0.005, 1, 0, 0);
|
| 667 |
}
|
| 668 |
if (activeKeys.includes("KeyQ")) {
|
| 669 |
-
// Roll counterclockwise (Z axis rotation)
|
| 670 |
inv = rotate4(inv, 0.01, 0, 0, 1);
|
| 671 |
}
|
| 672 |
if (activeKeys.includes("KeyE")) {
|
| 673 |
-
// Roll clockwise (Z axis rotation)
|
| 674 |
inv = rotate4(inv, -0.01, 0, 0, 1);
|
| 675 |
}
|
| 676 |
|
| 677 |
-
// Orbit (
|
| 678 |
if (activeKeys.includes("KeyI") || activeKeys.includes("KeyK") ||
|
| 679 |
activeKeys.includes("KeyJ") || activeKeys.includes("KeyL")) {
|
| 680 |
let d = 4;
|
|
@@ -692,17 +686,16 @@ export function preprocessManual(vrmPath, gsPath, scene, camera, renderer, stage
|
|
| 692 |
inv = translate4(inv, 0, 0, -d);
|
| 693 |
}
|
| 694 |
|
| 695 |
-
// Apply
|
| 696 |
const newMatrix = invert4(inv);
|
| 697 |
if (newMatrix) {
|
| 698 |
camera.matrix.fromArray(newMatrix);
|
| 699 |
camera.matrix.decompose(camera.position, camera.quaternion, camera.scale);
|
| 700 |
camera.updateMatrixWorld(true);
|
| 701 |
|
| 702 |
-
//
|
| 703 |
if (cameraControls && cameraControls.controls) {
|
| 704 |
cameraControls.controls.enabled = false;
|
| 705 |
-
// Re-enable after a short delay
|
| 706 |
setTimeout(() => {
|
| 707 |
if (cameraControls && cameraControls.controls) {
|
| 708 |
cameraControls.controls.enabled = true;
|
|
@@ -712,86 +705,94 @@ export function preprocessManual(vrmPath, gsPath, scene, camera, renderer, stage
|
|
| 712 |
}
|
| 713 |
}
|
| 714 |
|
| 715 |
-
//
|
| 716 |
-
function
|
| 717 |
-
|
| 718 |
-
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
|
| 722 |
-
let b05 = a[2] * a[7] - a[3] * a[6];
|
| 723 |
-
let b06 = a[8] * a[13] - a[9] * a[12];
|
| 724 |
-
let b07 = a[8] * a[14] - a[10] * a[12];
|
| 725 |
-
let b08 = a[8] * a[15] - a[11] * a[12];
|
| 726 |
-
let b09 = a[9] * a[14] - a[10] * a[13];
|
| 727 |
-
let b10 = a[9] * a[15] - a[11] * a[13];
|
| 728 |
-
let b11 = a[10] * a[15] - a[11] * a[14];
|
| 729 |
-
let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
|
| 730 |
-
if (!det) return null;
|
| 731 |
-
return [
|
| 732 |
-
(a[5] * b11 - a[6] * b10 + a[7] * b09) / det,
|
| 733 |
-
(a[2] * b10 - a[1] * b11 - a[3] * b09) / det,
|
| 734 |
-
(a[13] * b05 - a[14] * b04 + a[15] * b03) / det,
|
| 735 |
-
(a[10] * b04 - a[9] * b05 - a[11] * b03) / det,
|
| 736 |
-
(a[6] * b08 - a[4] * b11 - a[7] * b07) / det,
|
| 737 |
-
(a[0] * b11 - a[2] * b08 + a[3] * b07) / det,
|
| 738 |
-
(a[14] * b02 - a[12] * b05 - a[15] * b01) / det,
|
| 739 |
-
(a[8] * b05 - a[10] * b02 + a[11] * b01) / det,
|
| 740 |
-
(a[4] * b10 - a[5] * b08 + a[7] * b06) / det,
|
| 741 |
-
(a[1] * b08 - a[0] * b10 - a[3] * b06) / det,
|
| 742 |
-
(a[12] * b04 - a[13] * b02 + a[15] * b00) / det,
|
| 743 |
-
(a[9] * b02 - a[8] * b04 - a[11] * b00) / det,
|
| 744 |
-
(a[5] * b07 - a[4] * b09 - a[6] * b06) / det,
|
| 745 |
-
(a[0] * b09 - a[1] * b07 + a[2] * b06) / det,
|
| 746 |
-
(a[13] * b01 - a[12] * b03 - a[14] * b00) / det,
|
| 747 |
-
(a[8] * b03 - a[9] * b01 + a[10] * b00) / det,
|
| 748 |
-
];
|
| 749 |
-
}
|
| 750 |
|
| 751 |
-
|
| 752 |
-
|
| 753 |
-
|
| 754 |
-
y /= len;
|
| 755 |
-
z /= len;
|
| 756 |
-
let s = Math.sin(rad);
|
| 757 |
-
let c = Math.cos(rad);
|
| 758 |
-
let t = 1 - c;
|
| 759 |
-
let b00 = x * x * t + c;
|
| 760 |
-
let b01 = y * x * t + z * s;
|
| 761 |
-
let b02 = z * x * t - y * s;
|
| 762 |
-
let b10 = x * y * t - z * s;
|
| 763 |
-
let b11 = y * y * t + c;
|
| 764 |
-
let b12 = z * y * t + x * s;
|
| 765 |
-
let b20 = x * z * t + y * s;
|
| 766 |
-
let b21 = y * z * t - x * s;
|
| 767 |
-
let b22 = z * z * t + c;
|
| 768 |
-
return [
|
| 769 |
-
a[0] * b00 + a[4] * b01 + a[8] * b02,
|
| 770 |
-
a[1] * b00 + a[5] * b01 + a[9] * b02,
|
| 771 |
-
a[2] * b00 + a[6] * b01 + a[10] * b02,
|
| 772 |
-
a[3] * b00 + a[7] * b01 + a[11] * b02,
|
| 773 |
-
a[0] * b10 + a[4] * b11 + a[8] * b12,
|
| 774 |
-
a[1] * b10 + a[5] * b11 + a[9] * b12,
|
| 775 |
-
a[2] * b10 + a[6] * b11 + a[10] * b12,
|
| 776 |
-
a[3] * b10 + a[7] * b11 + a[11] * b12,
|
| 777 |
-
a[0] * b20 + a[4] * b21 + a[8] * b22,
|
| 778 |
-
a[1] * b20 + a[5] * b21 + a[9] * b22,
|
| 779 |
-
a[2] * b20 + a[6] * b21 + a[10] * b22,
|
| 780 |
-
a[3] * b20 + a[7] * b21 + a[11] * b22,
|
| 781 |
-
...a.slice(12, 16),
|
| 782 |
-
];
|
| 783 |
-
}
|
| 784 |
|
| 785 |
-
|
| 786 |
-
|
| 787 |
-
|
| 788 |
-
a[0] * x + a[4] * y + a[8] * z + a[12],
|
| 789 |
-
a[1] * x + a[5] * y + a[9] * z + a[13],
|
| 790 |
-
a[2] * x + a[6] * y + a[10] * z + a[14],
|
| 791 |
-
a[3] * x + a[7] * y + a[11] * z + a[15],
|
| 792 |
-
];
|
| 793 |
}
|
| 794 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 795 |
|
| 796 |
//////////////
|
| 797 |
|
|
@@ -886,11 +887,10 @@ export function preprocessManual(vrmPath, gsPath, scene, camera, renderer, stage
|
|
| 886 |
// ★★★ RESTART ANIMATION FOR BOX ADJUSTMENT ★★★
|
| 887 |
function animateBoxAdjustment() {
|
| 888 |
animationId = requestAnimationFrame(animateBoxAdjustment);
|
| 889 |
-
updateCameraFromKeys();
|
| 890 |
cameraControls.controls.update();
|
| 891 |
renderer.render(scene, camera);
|
| 892 |
}
|
| 893 |
-
|
| 894 |
animateBoxAdjustment();
|
| 895 |
|
| 896 |
let boxSize = { x: 2, y: 2, z: 2 };
|
|
|
|
| 529 |
return URL.createObjectURL(blob);
|
| 530 |
}
|
| 531 |
|
| 532 |
+
///////////////////////////////////////////////////12/23 14:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 533 |
|
| 534 |
// ========================================
|
| 535 |
+
// Keyboard Controls - Global Variables and Helper Functions
|
| 536 |
// ========================================
|
| 537 |
let activeKeys = [];
|
| 538 |
|
| 539 |
+
// Helper functions for matrix operations
|
| 540 |
+
function invert4(a) {
|
| 541 |
+
let b00 = a[0] * a[5] - a[1] * a[4];
|
| 542 |
+
let b01 = a[0] * a[6] - a[2] * a[4];
|
| 543 |
+
let b02 = a[0] * a[7] - a[3] * a[4];
|
| 544 |
+
let b03 = a[1] * a[6] - a[2] * a[5];
|
| 545 |
+
let b04 = a[1] * a[7] - a[3] * a[5];
|
| 546 |
+
let b05 = a[2] * a[7] - a[3] * a[6];
|
| 547 |
+
let b06 = a[8] * a[13] - a[9] * a[12];
|
| 548 |
+
let b07 = a[8] * a[14] - a[10] * a[12];
|
| 549 |
+
let b08 = a[8] * a[15] - a[11] * a[12];
|
| 550 |
+
let b09 = a[9] * a[14] - a[10] * a[13];
|
| 551 |
+
let b10 = a[9] * a[15] - a[11] * a[13];
|
| 552 |
+
let b11 = a[10] * a[15] - a[11] * a[14];
|
| 553 |
+
let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
|
| 554 |
+
if (!det) return null;
|
| 555 |
+
return [
|
| 556 |
+
(a[5] * b11 - a[6] * b10 + a[7] * b09) / det,
|
| 557 |
+
(a[2] * b10 - a[1] * b11 - a[3] * b09) / det,
|
| 558 |
+
(a[13] * b05 - a[14] * b04 + a[15] * b03) / det,
|
| 559 |
+
(a[10] * b04 - a[9] * b05 - a[11] * b03) / det,
|
| 560 |
+
(a[6] * b08 - a[4] * b11 - a[7] * b07) / det,
|
| 561 |
+
(a[0] * b11 - a[2] * b08 + a[3] * b07) / det,
|
| 562 |
+
(a[14] * b02 - a[12] * b05 - a[15] * b01) / det,
|
| 563 |
+
(a[8] * b05 - a[10] * b02 + a[11] * b01) / det,
|
| 564 |
+
(a[4] * b10 - a[5] * b08 + a[7] * b06) / det,
|
| 565 |
+
(a[1] * b08 - a[0] * b10 - a[3] * b06) / det,
|
| 566 |
+
(a[12] * b04 - a[13] * b02 + a[15] * b00) / det,
|
| 567 |
+
(a[9] * b02 - a[8] * b04 - a[11] * b00) / det,
|
| 568 |
+
(a[5] * b07 - a[4] * b09 - a[6] * b06) / det,
|
| 569 |
+
(a[0] * b09 - a[1] * b07 + a[2] * b06) / det,
|
| 570 |
+
(a[13] * b01 - a[12] * b03 - a[14] * b00) / det,
|
| 571 |
+
(a[8] * b03 - a[9] * b01 + a[10] * b00) / det,
|
| 572 |
+
];
|
| 573 |
+
}
|
| 574 |
|
| 575 |
+
function rotate4(a, rad, x, y, z) {
|
| 576 |
+
let len = Math.hypot(x, y, z);
|
| 577 |
+
x /= len;
|
| 578 |
+
y /= len;
|
| 579 |
+
z /= len;
|
| 580 |
+
let s = Math.sin(rad);
|
| 581 |
+
let c = Math.cos(rad);
|
| 582 |
+
let t = 1 - c;
|
| 583 |
+
let b00 = x * x * t + c;
|
| 584 |
+
let b01 = y * x * t + z * s;
|
| 585 |
+
let b02 = z * x * t - y * s;
|
| 586 |
+
let b10 = x * y * t - z * s;
|
| 587 |
+
let b11 = y * y * t + c;
|
| 588 |
+
let b12 = z * y * t + x * s;
|
| 589 |
+
let b20 = x * z * t + y * s;
|
| 590 |
+
let b21 = y * z * t - x * s;
|
| 591 |
+
let b22 = z * z * t + c;
|
| 592 |
+
return [
|
| 593 |
+
a[0] * b00 + a[4] * b01 + a[8] * b02,
|
| 594 |
+
a[1] * b00 + a[5] * b01 + a[9] * b02,
|
| 595 |
+
a[2] * b00 + a[6] * b01 + a[10] * b02,
|
| 596 |
+
a[3] * b00 + a[7] * b01 + a[11] * b02,
|
| 597 |
+
a[0] * b10 + a[4] * b11 + a[8] * b12,
|
| 598 |
+
a[1] * b10 + a[5] * b11 + a[9] * b12,
|
| 599 |
+
a[2] * b10 + a[6] * b11 + a[10] * b12,
|
| 600 |
+
a[3] * b10 + a[7] * b11 + a[11] * b12,
|
| 601 |
+
a[0] * b20 + a[4] * b21 + a[8] * b22,
|
| 602 |
+
a[1] * b20 + a[5] * b21 + a[9] * b22,
|
| 603 |
+
a[2] * b20 + a[6] * b21 + a[10] * b22,
|
| 604 |
+
a[3] * b20 + a[7] * b21 + a[11] * b22,
|
| 605 |
+
...a.slice(12, 16),
|
| 606 |
+
];
|
| 607 |
+
}
|
| 608 |
|
| 609 |
+
function translate4(a, x, y, z) {
|
| 610 |
+
return [
|
| 611 |
+
...a.slice(0, 12),
|
| 612 |
+
a[0] * x + a[4] * y + a[8] * z + a[12],
|
| 613 |
+
a[1] * x + a[5] * y + a[9] * z + a[13],
|
| 614 |
+
a[2] * x + a[6] * y + a[10] * z + a[14],
|
| 615 |
+
a[3] * x + a[7] * y + a[11] * z + a[15],
|
| 616 |
+
];
|
| 617 |
+
}
|
| 618 |
|
| 619 |
+
// Camera manipulation function
|
| 620 |
+
function updateCameraFromKeys(camera, cameraControls) {
|
| 621 |
if (activeKeys.length === 0) return;
|
| 622 |
|
| 623 |
+
// Get current camera matrix
|
| 624 |
let inv = invert4(camera.matrixWorld.elements);
|
| 625 |
if (!inv) return;
|
| 626 |
|
|
|
|
| 629 |
// Movement (arrow keys)
|
| 630 |
if (activeKeys.includes("ArrowUp")) {
|
| 631 |
if (shiftKey) {
|
|
|
|
| 632 |
inv = translate4(inv, 0, -0.03, 0);
|
| 633 |
} else {
|
|
|
|
| 634 |
inv = translate4(inv, 0, 0, 0.1);
|
| 635 |
}
|
| 636 |
}
|
| 637 |
if (activeKeys.includes("ArrowDown")) {
|
| 638 |
if (shiftKey) {
|
|
|
|
| 639 |
inv = translate4(inv, 0, 0.03, 0);
|
| 640 |
} else {
|
|
|
|
| 641 |
inv = translate4(inv, 0, 0, -0.1);
|
| 642 |
}
|
| 643 |
}
|
| 644 |
if (activeKeys.includes("ArrowLeft")) {
|
|
|
|
| 645 |
inv = translate4(inv, -0.03, 0, 0);
|
| 646 |
}
|
| 647 |
if (activeKeys.includes("ArrowRight")) {
|
|
|
|
| 648 |
inv = translate4(inv, 0.03, 0, 0);
|
| 649 |
}
|
| 650 |
|
| 651 |
+
// Camera angle (WASD)
|
| 652 |
if (activeKeys.includes("KeyA")) {
|
|
|
|
| 653 |
inv = rotate4(inv, -0.01, 0, 1, 0);
|
| 654 |
}
|
| 655 |
if (activeKeys.includes("KeyD")) {
|
|
|
|
| 656 |
inv = rotate4(inv, 0.01, 0, 1, 0);
|
| 657 |
}
|
| 658 |
if (activeKeys.includes("KeyW")) {
|
|
|
|
| 659 |
inv = rotate4(inv, 0.005, 1, 0, 0);
|
| 660 |
}
|
| 661 |
if (activeKeys.includes("KeyS")) {
|
|
|
|
| 662 |
inv = rotate4(inv, -0.005, 1, 0, 0);
|
| 663 |
}
|
| 664 |
if (activeKeys.includes("KeyQ")) {
|
|
|
|
| 665 |
inv = rotate4(inv, 0.01, 0, 0, 1);
|
| 666 |
}
|
| 667 |
if (activeKeys.includes("KeyE")) {
|
|
|
|
| 668 |
inv = rotate4(inv, -0.01, 0, 0, 1);
|
| 669 |
}
|
| 670 |
|
| 671 |
+
// Orbit (IJKL)
|
| 672 |
if (activeKeys.includes("KeyI") || activeKeys.includes("KeyK") ||
|
| 673 |
activeKeys.includes("KeyJ") || activeKeys.includes("KeyL")) {
|
| 674 |
let d = 4;
|
|
|
|
| 686 |
inv = translate4(inv, 0, 0, -d);
|
| 687 |
}
|
| 688 |
|
| 689 |
+
// Apply transformation
|
| 690 |
const newMatrix = invert4(inv);
|
| 691 |
if (newMatrix) {
|
| 692 |
camera.matrix.fromArray(newMatrix);
|
| 693 |
camera.matrix.decompose(camera.position, camera.quaternion, camera.scale);
|
| 694 |
camera.updateMatrixWorld(true);
|
| 695 |
|
| 696 |
+
// Temporarily disable OrbitControls
|
| 697 |
if (cameraControls && cameraControls.controls) {
|
| 698 |
cameraControls.controls.enabled = false;
|
|
|
|
| 699 |
setTimeout(() => {
|
| 700 |
if (cameraControls && cameraControls.controls) {
|
| 701 |
cameraControls.controls.enabled = true;
|
|
|
|
| 705 |
}
|
| 706 |
}
|
| 707 |
|
| 708 |
+
// Set up keyboard event listeners (call once)
|
| 709 |
+
function setupKeyboardControls() {
|
| 710 |
+
window.addEventListener("keydown", (e) => {
|
| 711 |
+
if (!activeKeys.includes(e.code)) {
|
| 712 |
+
activeKeys.push(e.code);
|
| 713 |
+
}
|
| 714 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 715 |
|
| 716 |
+
window.addEventListener("keyup", (e) => {
|
| 717 |
+
activeKeys = activeKeys.filter((k) => k !== e.code);
|
| 718 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 719 |
|
| 720 |
+
window.addEventListener("blur", () => {
|
| 721 |
+
activeKeys = [];
|
| 722 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 723 |
}
|
| 724 |
|
| 725 |
+
/////////////////////////////////////////////////
|
| 726 |
+
|
| 727 |
+
/**
|
| 728 |
+
* Manual preprocessing - メイン関数
|
| 729 |
+
*/
|
| 730 |
+
|
| 731 |
+
|
| 732 |
+
export function preprocessManual(vrmPath, gsPath, scene, camera, renderer, stage, useGPU, noBG, noCheck, fileName, savePly) {
|
| 733 |
+
|
| 734 |
+
console.log('[preprocessManual] ===== FUNCTION CALLED =====');
|
| 735 |
+
console.log('[preprocessManual] Parameters:');
|
| 736 |
+
console.log(' vrmPath:', vrmPath);
|
| 737 |
+
console.log(' gsPath:', gsPath);
|
| 738 |
+
console.log(' fileName:', fileName);
|
| 739 |
+
|
| 740 |
+
return new Promise((resolve, reject) => {
|
| 741 |
+
console.log('[preprocessManual] Creating Promise...');
|
| 742 |
+
|
| 743 |
+
try {
|
| 744 |
+
const ui = createManualUI(scene, camera, renderer);
|
| 745 |
+
console.log('[preprocessManual] UI created');
|
| 746 |
+
|
| 747 |
+
ui.initialize().then(() => {
|
| 748 |
+
console.log('[preprocessManual] UI initialized, starting manual process...');
|
| 749 |
+
|
| 750 |
+
ui.show();
|
| 751 |
+
ui.setStatus('Loading PLY file...');
|
| 752 |
+
|
| 753 |
+
// PLYファイルの読み込み
|
| 754 |
+
const parser = new PLYParser();
|
| 755 |
+
let loadingSpinner = new DropInViewer().viewer.loadingSpinner;
|
| 756 |
+
const task = loadingSpinner.addTask('Loading PLY...');
|
| 757 |
+
|
| 758 |
+
parser.parsePLY(gsPath, true).then((plyData) => {
|
| 759 |
+
console.log('[preprocessManual] PLY loaded:', plyData.vertices.length, 'vertices');
|
| 760 |
+
loadingSpinner.removeTask(task);
|
| 761 |
+
|
| 762 |
+
// GSの初期表示, replace all 20251207
|
| 763 |
+
GVRM.initGS(gsPath, undefined, undefined, scene).then((gs) => {
|
| 764 |
+
console.log('[preprocessManual] GS initialized');
|
| 765 |
+
|
| 766 |
+
// ★★★ ADD CAMERA CONTROLS HERE ★★★
|
| 767 |
+
const cameraControls = setupCameraControls(camera, renderer);
|
| 768 |
+
|
| 769 |
+
// ⭐ Initialize keyboard controls 12/13 14:00
|
| 770 |
+
setupKeyboardControls();
|
| 771 |
+
|
| 772 |
+
// Animation loop for smooth camera controls
|
| 773 |
+
let animationId = null;
|
| 774 |
+
function animateControls() {
|
| 775 |
+
animationId = requestAnimationFrame(animateControls);
|
| 776 |
+
updateCameraFromKeys(camera, cameraControls);
|
| 777 |
+
cameraControls.controls.update();
|
| 778 |
+
renderer.render(scene, camera);
|
| 779 |
+
}
|
| 780 |
+
|
| 781 |
+
animateControls();
|
| 782 |
+
|
| 783 |
+
// Cleanup function to stop animation
|
| 784 |
+
const cleanupAnimation = () => {
|
| 785 |
+
if (animationId) {
|
| 786 |
+
cancelAnimationFrame(animationId);
|
| 787 |
+
animationId = null;
|
| 788 |
+
}
|
| 789 |
+
};
|
| 790 |
+
|
| 791 |
+
//////////////// handle key 12/13 13:30
|
| 792 |
+
|
| 793 |
+
// ========================================
|
| 794 |
+
// Keyboard Controls for Camera Movement: Deleted 12/13 13:50
|
| 795 |
+
// ========================================
|
| 796 |
|
| 797 |
//////////////
|
| 798 |
|
|
|
|
| 887 |
// ★★★ RESTART ANIMATION FOR BOX ADJUSTMENT ★★★
|
| 888 |
function animateBoxAdjustment() {
|
| 889 |
animationId = requestAnimationFrame(animateBoxAdjustment);
|
| 890 |
+
updateCameraFromKeys(camera, cameraControls);
|
| 891 |
cameraControls.controls.update();
|
| 892 |
renderer.render(scene, camera);
|
| 893 |
}
|
|
|
|
| 894 |
animateBoxAdjustment();
|
| 895 |
|
| 896 |
let boxSize = { x: 2, y: 2, z: 2 };
|