Upload 2 files
Browse files- log.md +50 -96
- preprocess_manual.js +283 -216
log.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
|
| 2 |
-
[preprocess_manual.js] ===== MODULE LOADING =====
|
| 3 |
main.js:16 [MAIN] DOMContentLoaded fired
|
| 4 |
main.js:269 [MAIN] Calling setupPathsFromUrlOrSelect...
|
| 5 |
main.js:46 [MAIN] setupPathsFromUrlOrSelect started
|
|
@@ -21,32 +21,32 @@ main.js:190 [MAIN] Manual file selected: fountain_trim8.ply Extension: ply
|
|
| 21 |
main.js:198 [MAIN] Reading manual file...
|
| 22 |
main.js:201 [MAIN] Manual file read complete, size: 63528715
|
| 23 |
main.js:209 [MAIN] Manual mode file loaded: fountain_trim8.ply
|
| 24 |
-
main.js:210 [MAIN] gsPath: blob:http://127.0.0.1:5500/
|
| 25 |
main.js:211 [MAIN] gsFileName: fountain_trim8.ply
|
| 26 |
main.js:110 [MAIN] Hiding select UI
|
| 27 |
main.js:215 [MAIN] ===== Resolving with MANUAL MODE =====
|
| 28 |
-
main.js:261 [MAIN] File load promise resolved: ObjectgsPath: "blob:http://127.0.0.1:5500/
|
| 29 |
-
main.js:271 [MAIN] setupPathsFromUrlOrSelect returned: ObjectgsPath: "blob:http://127.0.0.1:5500/
|
| 30 |
main.js:277 [MAIN] After pathResult:
|
| 31 |
-
main.js:278 - gsPath: blob:http://127.0.0.1:5500/
|
| 32 |
main.js:279 - gvrmPath: undefined
|
| 33 |
main.js:280 - isManualMode: true
|
| 34 |
main.js:283 [MAIN] Initializing renderer...
|
| 35 |
main.js:289 [MAIN] Initializing camera...
|
| 36 |
main.js:316 [MAIN] Initializing scene...
|
| 37 |
main.js:323 [MAIN] Three.js initialization complete
|
| 38 |
-
main.js:506 [MAIN] Processing GS file: blob:http://127.0.0.1:5500/
|
| 39 |
main.js:507 [MAIN] Manual mode: true
|
| 40 |
main.js:519 [MAIN] fileName: fountain_trim8.gvrm
|
| 41 |
main.js:529 [MAIN] ===== STARTING MANUAL PREPROCESSING MODE =====
|
| 42 |
main.js:530 [MAIN] Parameters:
|
| 43 |
main.js:531 - vrmPath: ./assets/sotai.vrm
|
| 44 |
-
main.js:532 - gsPath: blob:http://127.0.0.1:5500/
|
| 45 |
main.js:533 - fileName: fountain_trim8.gvrm
|
| 46 |
preprocess_manual.js:977 [preprocessManual] ===== FUNCTION CALLED =====
|
| 47 |
preprocess_manual.js:978 [preprocessManual] Parameters:
|
| 48 |
preprocess_manual.js:979 vrmPath: ./assets/sotai.vrm
|
| 49 |
-
preprocess_manual.js:980 gsPath: blob:http://127.0.0.1:5500/
|
| 50 |
preprocess_manual.js:981 fileName: fountain_trim8.gvrm
|
| 51 |
preprocess_manual.js:984 [preprocessManual] Creating Promise...
|
| 52 |
preprocess_manual.js:84 [createManualUI] Creating manual preprocessing UI...
|
|
@@ -60,92 +60,46 @@ preprocess_manual.js:1026 [PCA] Center: Objectx: -0.2865427244435473y: 1.1463828
|
|
| 60 |
preprocess_manual.js:1052 [PCA] Covariance matrix: Objectcxx: "0.36"cxy: "0.14"cxz: "0.06"cyy: "1.01"cyz: "0.95"czz: "1.20"[[Prototype]]: Object
|
| 61 |
preprocess_manual.js:1067 [PCA] Variance ratios: Objectx: "14.1%"y: "39.2%"z: "46.7%"[[Prototype]]: Object
|
| 62 |
preprocess_manual.js:1080 [PCA] Is aligned with world axes: false
|
| 63 |
-
preprocess_manual.js:
|
| 64 |
-
preprocess_manual.js:
|
| 65 |
-
preprocess_manual.js:
|
| 66 |
-
preprocess_manual.js:
|
| 67 |
-
preprocess_manual.js:
|
| 68 |
-
preprocess_manual.js:
|
| 69 |
-
preprocess_manual.js:
|
| 70 |
-
preprocess_manual.js:
|
| 71 |
-
preprocess_manual.js:
|
| 72 |
-
preprocess_manual.js:
|
| 73 |
-
preprocess_manual.js:
|
| 74 |
-
preprocess_manual.js:
|
| 75 |
-
preprocess_manual.js:
|
| 76 |
-
preprocess_manual.js:
|
| 77 |
-
preprocess_manual.js:
|
| 78 |
-
preprocess_manual.js:
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
preprocess_manual.js:
|
| 82 |
-
preprocess_manual.js:
|
| 83 |
-
preprocess_manual.js:
|
| 84 |
-
preprocess_manual.js:
|
| 85 |
-
preprocess_manual.js:
|
| 86 |
-
preprocess_manual.js:
|
| 87 |
-
preprocess_manual.js:
|
| 88 |
-
preprocess_manual.js:
|
| 89 |
-
preprocess_manual.js:
|
| 90 |
-
preprocess_manual.js:
|
| 91 |
-
preprocess_manual.js:
|
| 92 |
-
preprocess_manual.js:
|
| 93 |
-
|
| 94 |
-
preprocess_manual.js:1767 plyOffset: Objectx: -1.4y: 2.6z: 1.4[[Prototype]]: Object
|
| 95 |
-
preprocess_manual.js:1771 [STEP 2] Centered PLY Data (should be ~0,0,0):
|
| 96 |
-
preprocess_manual.js:1772 Total vertices: 256158
|
| 97 |
-
preprocess_manual.js:1786 Centered bounds:
|
| 98 |
-
preprocess_manual.js:1787 X: -1.400 to 2.970
|
| 99 |
-
preprocess_manual.js:1788 Y: -1.173 to 3.243
|
| 100 |
-
preprocess_manual.js:1789 Z: -0.838 to 3.117
|
| 101 |
-
preprocess_manual.js:1797 Centered center: Object
|
| 102 |
-
error.js:58 [STEP 2] โ ERROR: PLY is NOT properly centered!
|
| 103 |
-
console.error @ error.js:58Understand this error
|
| 104 |
-
error.js:58 [STEP 2] Expected ~(0,0,0) but got: Object
|
| 105 |
-
console.error @ error.js:58Understand this error
|
| 106 |
-
error.js:58 [STEP 2] This will cause Box filtering to fail!
|
| 107 |
-
console.error @ error.js:58Understand this error
|
| 108 |
-
preprocess_manual.js:1812 [STEP 2] Emergency re-centering...
|
| 109 |
-
preprocess_manual.js:1818 [STEP 2] โ PLY force-centered to origin
|
| 110 |
-
preprocess_manual.js:1825 [STEP 3] Applying PLY offset: Objectx: -1.4y: 2.6z: 1.4[[Prototype]]: Object
|
| 111 |
-
preprocess_manual.js:1833 [STEP 3] โ PLY data updated with offset
|
| 112 |
-
preprocess_manual.js:1842 [STEP 3] โ GS reloaded with adjusted position
|
| 113 |
-
preprocess_manual.js:1851 Uncaught (in promise) ReferenceError: Cannot access 'filteredVertices' before initialization
|
| 114 |
-
at HTMLButtonElement.<anonymous> (preprocess_manual.js:1851:21)Understand this error
|
| 115 |
-
preprocess_manual.js:1720
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
preprocess_manual.js:1721 โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 119 |
-
preprocess_manual.js:1722 CONFIRM BOX BUTTON CLICKED
|
| 120 |
-
preprocess_manual.js:1723 โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 121 |
-
preprocess_manual.js:1751 [STEP 1] Current BOX Settings (from UI):
|
| 122 |
-
preprocess_manual.js:1752 Box Size: Objectx: 5.8y: 6.7z: 6.5[[Prototype]]: Object
|
| 123 |
-
preprocess_manual.js:1753 Box Position: Objectx: 0y: 0z: 2.4[[Prototype]]: Object
|
| 124 |
-
preprocess_manual.js:1754 Box Rotation (radians): Objectx: 0.5061454830783556y: 0z: 0[[Prototype]]: Object
|
| 125 |
-
preprocess_manual.js:1755 Box Rotation (degrees): Objectx: "29.0ยฐ"y: "0.0ยฐ"z: "0.0ยฐ"[[Prototype]]: Object
|
| 126 |
-
preprocess_manual.js:1760 PLY Offset: Object
|
| 127 |
-
preprocess_manual.js:1763 [STEP 1] Outer scope variables (for comparison):
|
| 128 |
-
preprocess_manual.js:1764 boxSize: Object
|
| 129 |
-
preprocess_manual.js:1765 boxPosition: Objectx: 0y: 0z: 2.4[[Prototype]]: Object
|
| 130 |
-
preprocess_manual.js:1766 boxRotation: Objectx: 0.5061454830783556y: 0z: 0[[Prototype]]: Object
|
| 131 |
-
preprocess_manual.js:1767 plyOffset: Objectx: 0y: 0z: 0[[Prototype]]: Object
|
| 132 |
-
preprocess_manual.js:1771 [STEP 2] Centered PLY Data (should be ~0,0,0):
|
| 133 |
-
preprocess_manual.js:1772 Total vertices: 256158
|
| 134 |
-
preprocess_manual.js:1786 Centered bounds:
|
| 135 |
-
preprocess_manual.js:1787 X: -3.585 to 0.785
|
| 136 |
-
preprocess_manual.js:1788 Y: 0.392 to 4.808
|
| 137 |
-
preprocess_manual.js:1789 Z: -0.577 to 3.377
|
| 138 |
-
preprocess_manual.js:1797 Centered center: Objectx: "-1.400"y: "2.600"z: "1.400"[[Prototype]]: Object
|
| 139 |
-
error.js:58 [STEP 2] โ ERROR: PLY is NOT properly centered!
|
| 140 |
-
console.error @ error.js:58Understand this error
|
| 141 |
-
error.js:58 [STEP 2] Expected ~(0,0,0) but got: Object
|
| 142 |
-
console.error @ error.js:58Understand this error
|
| 143 |
-
error.js:58 [STEP 2] This will cause Box filtering to fail!
|
| 144 |
console.error @ error.js:58Understand this error
|
| 145 |
-
preprocess_manual.js:
|
| 146 |
-
preprocess_manual.js:
|
| 147 |
-
preprocess_manual.js:
|
| 148 |
-
preprocess_manual.js:
|
| 149 |
-
preprocess_manual.js:
|
| 150 |
-
preprocess_manual.js:
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
+
preprocess_manual.js:16 [preprocess_manual.js] ===== MODULE LOADING =====
|
| 3 |
main.js:16 [MAIN] DOMContentLoaded fired
|
| 4 |
main.js:269 [MAIN] Calling setupPathsFromUrlOrSelect...
|
| 5 |
main.js:46 [MAIN] setupPathsFromUrlOrSelect started
|
|
|
|
| 21 |
main.js:198 [MAIN] Reading manual file...
|
| 22 |
main.js:201 [MAIN] Manual file read complete, size: 63528715
|
| 23 |
main.js:209 [MAIN] Manual mode file loaded: fountain_trim8.ply
|
| 24 |
+
main.js:210 [MAIN] gsPath: blob:http://127.0.0.1:5500/551c8892-9628-4bad-8aa4-b7c4ee09957a
|
| 25 |
main.js:211 [MAIN] gsFileName: fountain_trim8.ply
|
| 26 |
main.js:110 [MAIN] Hiding select UI
|
| 27 |
main.js:215 [MAIN] ===== Resolving with MANUAL MODE =====
|
| 28 |
+
main.js:261 [MAIN] File load promise resolved: ObjectgsPath: "blob:http://127.0.0.1:5500/551c8892-9628-4bad-8aa4-b7c4ee09957a"gvrmPath: undefinedmanualMode: true[[Prototype]]: Object
|
| 29 |
+
main.js:271 [MAIN] setupPathsFromUrlOrSelect returned: ObjectgsPath: "blob:http://127.0.0.1:5500/551c8892-9628-4bad-8aa4-b7c4ee09957a"gvrmPath: undefinedmanualMode: true[[Prototype]]: Object
|
| 30 |
main.js:277 [MAIN] After pathResult:
|
| 31 |
+
main.js:278 - gsPath: blob:http://127.0.0.1:5500/551c8892-9628-4bad-8aa4-b7c4ee09957a
|
| 32 |
main.js:279 - gvrmPath: undefined
|
| 33 |
main.js:280 - isManualMode: true
|
| 34 |
main.js:283 [MAIN] Initializing renderer...
|
| 35 |
main.js:289 [MAIN] Initializing camera...
|
| 36 |
main.js:316 [MAIN] Initializing scene...
|
| 37 |
main.js:323 [MAIN] Three.js initialization complete
|
| 38 |
+
main.js:506 [MAIN] Processing GS file: blob:http://127.0.0.1:5500/551c8892-9628-4bad-8aa4-b7c4ee09957a
|
| 39 |
main.js:507 [MAIN] Manual mode: true
|
| 40 |
main.js:519 [MAIN] fileName: fountain_trim8.gvrm
|
| 41 |
main.js:529 [MAIN] ===== STARTING MANUAL PREPROCESSING MODE =====
|
| 42 |
main.js:530 [MAIN] Parameters:
|
| 43 |
main.js:531 - vrmPath: ./assets/sotai.vrm
|
| 44 |
+
main.js:532 - gsPath: blob:http://127.0.0.1:5500/551c8892-9628-4bad-8aa4-b7c4ee09957a
|
| 45 |
main.js:533 - fileName: fountain_trim8.gvrm
|
| 46 |
preprocess_manual.js:977 [preprocessManual] ===== FUNCTION CALLED =====
|
| 47 |
preprocess_manual.js:978 [preprocessManual] Parameters:
|
| 48 |
preprocess_manual.js:979 vrmPath: ./assets/sotai.vrm
|
| 49 |
+
preprocess_manual.js:980 gsPath: blob:http://127.0.0.1:5500/551c8892-9628-4bad-8aa4-b7c4ee09957a
|
| 50 |
preprocess_manual.js:981 fileName: fountain_trim8.gvrm
|
| 51 |
preprocess_manual.js:984 [preprocessManual] Creating Promise...
|
| 52 |
preprocess_manual.js:84 [createManualUI] Creating manual preprocessing UI...
|
|
|
|
| 60 |
preprocess_manual.js:1052 [PCA] Covariance matrix: Objectcxx: "0.36"cxy: "0.14"cxz: "0.06"cyy: "1.01"cyz: "0.95"czz: "1.20"[[Prototype]]: Object
|
| 61 |
preprocess_manual.js:1067 [PCA] Variance ratios: Objectx: "14.1%"y: "39.2%"z: "46.7%"[[Prototype]]: Object
|
| 62 |
preprocess_manual.js:1080 [PCA] Is aligned with world axes: false
|
| 63 |
+
preprocess_manual.js:1120 [preprocessManual] ===== PLY DATA LOADED =====
|
| 64 |
+
preprocess_manual.js:1121 [preprocessManual] PLY data is in CAMERA coordinate space
|
| 65 |
+
preprocess_manual.js:1122 Total vertices: 256158
|
| 66 |
+
preprocess_manual.js:1141 [preprocessManual] PLY bounds (CAMERA space):
|
| 67 |
+
preprocess_manual.js:1142 Min: Objectx: "-1.400"y: "-1.173"z: "-0.838"[[Prototype]]: Object
|
| 68 |
+
preprocess_manual.js:1143 Max: Objectx: "2.970"y: "3.243"z: "3.117"[[Prototype]]: Object
|
| 69 |
+
preprocess_manual.js:1144 Center: Objectx: "0.785"y: "1.035"z: "1.139"[[Prototype]]: Object
|
| 70 |
+
preprocess_manual.js:1150 [preprocessManual] โ PLY coordinates preserved (CAMERA space)
|
| 71 |
+
preprocess_manual.js:1219 [preprocessManual] โ Coordinate transformation functions defined
|
| 72 |
+
preprocess_manual.js:1346 [filterWithWorldBox] ===== COMPLETE FILTERING PROCESS =====
|
| 73 |
+
preprocess_manual.js:1349 [filterWithWorldBox] Step 1: Transform box to camera space
|
| 74 |
+
preprocess_manual.js:1350 World box: Objectmax: {x: 1, y: 1, z: 1}min: {x: 0, y: 0, z: 0}[[Prototype]]: Object
|
| 75 |
+
preprocess_manual.js:1354 [filterWithWorldBox] โ Transformed to camera space: Objectmax: {x: 1, y: 0.9486832980505138, z: -1.2649110640673515}min: {x: 0, y: -0.31622776601683816, z: -2.5298221281347035}[[Prototype]]: Object
|
| 76 |
+
preprocess_manual.js:1357 [filterWithWorldBox] Step 2: Display box in camera space
|
| 77 |
+
preprocess_manual.js:1247 [createCameraSpaceBox] Creating box in CAMERA space:
|
| 78 |
+
preprocess_manual.js:1248 Min: Objectx: 0y: -0.31622776601683816z: -2.5298221281347035[[Prototype]]: Object
|
| 79 |
+
preprocess_manual.js:1249 Max: Objectx: 1y: 0.9486832980505138z: -1.2649110640673515[[Prototype]]: Object
|
| 80 |
+
preprocess_manual.js:1250 Center: Objectx: 0.5y: 0.3162277660168378z: -1.8973665961010275[[Prototype]]: Object
|
| 81 |
+
preprocess_manual.js:1251 Size: Objectx: 1y: 1.264911064067352z: 1.264911064067352[[Prototype]]: Object
|
| 82 |
+
preprocess_manual.js:1265 [createCameraSpaceBox] โ Box added in camera space
|
| 83 |
+
preprocess_manual.js:1361 [filterWithWorldBox] โ Box displayed
|
| 84 |
+
preprocess_manual.js:1364 [filterWithWorldBox] Step 3: Filter splats in camera space
|
| 85 |
+
preprocess_manual.js:1283 [filterSplatsByCameraBox] ===== FILTERING START =====
|
| 86 |
+
preprocess_manual.js:1284 [filterSplatsByCameraBox] CAMERA-space box:
|
| 87 |
+
preprocess_manual.js:1285 Min: Objectx: 0y: -0.31622776601683816z: -2.5298221281347035[[Prototype]]: Object
|
| 88 |
+
preprocess_manual.js:1286 Max: Objectx: 1y: 0.9486832980505138z: -1.2649110640673515[[Prototype]]: Object
|
| 89 |
+
preprocess_manual.js:1287 Total vertices: 256158
|
| 90 |
+
preprocess_manual.js:1302 [filterSplatsByCameraBox] ===== FILTERING COMPLETE =====
|
| 91 |
+
preprocess_manual.js:1303 Filtered: 0 / 256158
|
| 92 |
+
preprocess_manual.js:1304 Retention rate: 0.0 %
|
| 93 |
+
error.js:58 [filterSplatsByCameraBox] โ No vertices in box!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
console.error @ error.js:58Understand this error
|
| 95 |
+
preprocess_manual.js:1368 [filterWithWorldBox] โ Filtering complete: 0 vertices
|
| 96 |
+
preprocess_manual.js:1370 [filterWithWorldBox] ===== PROCESS COMPLETE =====
|
| 97 |
+
preprocess_manual.js:1393 Result: 0 vertices filtered
|
| 98 |
+
preprocess_manual.js:1492 [preprocessManual] GS initialized
|
| 99 |
+
preprocess_manual.js:1511 [preprocessManual] No alignment transform needed for GS
|
| 100 |
+
preprocess_manual.js:1518 [preprocessManual] Camera controls initialized
|
| 101 |
+
preprocess_manual.js:1524 [preprocessManual] Keyboard controls initialized
|
| 102 |
+
preprocess_manual.js:1588 [preprocessManual] Camera positioned at: Objectx: "0.00"y: "1.32"z: "8.83"[[Prototype]]: Object
|
| 103 |
+
preprocess_manual.js:1593 [preprocessManual] Initial box setup - size: Objectx: 5.243591022491455y: 5.299250650405884z: 4.745910859107971[[Prototype]]: Object
|
| 104 |
+
preprocess_manual.js:1636 [preprocessManual] UI sliders initialized to PLY-aligned values
|
| 105 |
+
preprocess_manual.js:1642 [preprocessManual] โ Camera and Box aligned to PLY
|
preprocess_manual.js
CHANGED
|
@@ -1109,315 +1109,382 @@ parser.parsePLY(gsPath, true).then((plyData) => {
|
|
| 1109 |
// ใใใใฐ็: PLYไธญๅฟๅ๏ผLine 1107-1330ใ็ฝฎใๆใ๏ผ
|
| 1110 |
// ๅในใใใใง้
ๅใฎๅ็
งใ็ขบ่ช
|
| 1111 |
// ========================================
|
|
|
|
| 1112 |
|
| 1113 |
-
console.log('[preprocessManual] ===== STARTING AUTO-ALIGNMENT =====');
|
| 1114 |
|
| 1115 |
-
//
|
| 1116 |
-
|
| 1117 |
-
|
| 1118 |
-
|
| 1119 |
-
|
| 1120 |
-
|
| 1121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1122 |
});
|
| 1123 |
-
///////////////////ไธ็ๅบงๆจโใซใกใฉๅบงๆจใฎๅคๆ้ขๆฐใ่ฟฝๅ
|
| 1124 |
|
| 1125 |
-
|
| 1126 |
-
console.log('[preprocessManual] PLY data loaded with original coordinates');
|
| 1127 |
|
| 1128 |
|
| 1129 |
// ========================================
|
| 1130 |
-
//
|
| 1131 |
// ========================================
|
| 1132 |
|
| 1133 |
/**
|
| 1134 |
-
*
|
| 1135 |
* @param {THREE.Vector3} worldPos - ไธ็ๅบงๆจใฎไฝ็ฝฎ
|
| 1136 |
* @param {THREE.Camera} camera - ใซใกใฉใชใใธใงใฏใ
|
| 1137 |
-
* @returns {THREE.Vector3}
|
| 1138 |
*/
|
| 1139 |
function worldToCameraSpace(worldPos, camera) {
|
| 1140 |
const cameraPos = worldPos.clone();
|
| 1141 |
|
| 1142 |
-
//
|
| 1143 |
camera.updateMatrixWorld();
|
| 1144 |
-
|
| 1145 |
-
|
|
|
|
|
|
|
| 1146 |
|
| 1147 |
return cameraPos;
|
| 1148 |
}
|
| 1149 |
|
| 1150 |
/**
|
| 1151 |
-
*
|
| 1152 |
-
* @param {
|
| 1153 |
* @param {THREE.Camera} camera - ใซใกใฉใชใใธใงใฏใ
|
| 1154 |
-
* @returns {
|
| 1155 |
*/
|
| 1156 |
-
function
|
| 1157 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1158 |
|
| 1159 |
-
//
|
| 1160 |
-
|
| 1161 |
|
| 1162 |
-
//
|
| 1163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1164 |
}
|
| 1165 |
|
|
|
|
|
|
|
| 1166 |
|
| 1167 |
// ========================================
|
| 1168 |
-
//
|
| 1169 |
-
// ใซใกใฉๅบงๆจใซๅคๆใใฆ่กจ็คบ
|
| 1170 |
// ========================================
|
| 1171 |
|
| 1172 |
/**
|
| 1173 |
-
*
|
| 1174 |
-
* @param {Object}
|
| 1175 |
* @param {THREE.Scene} scene - Three.jsใทใผใณ
|
| 1176 |
-
* @
|
| 1177 |
*/
|
| 1178 |
-
function
|
| 1179 |
-
|
| 1180 |
-
|
| 1181 |
-
if (boxDef.min && boxDef.max) {
|
| 1182 |
-
// min/maxๅฝขๅผ
|
| 1183 |
-
({ x: minX, y: minY, z: minZ } = boxDef.min);
|
| 1184 |
-
({ x: maxX, y: maxY, z: maxZ } = boxDef.max);
|
| 1185 |
-
} else if (boxDef.center && boxDef.size) {
|
| 1186 |
-
// center/sizeๅฝขๅผ
|
| 1187 |
-
const { center, size } = boxDef;
|
| 1188 |
-
minX = center.x - size.x / 2;
|
| 1189 |
-
minY = center.y - size.y / 2;
|
| 1190 |
-
minZ = center.z - size.z / 2;
|
| 1191 |
-
maxX = center.x + size.x / 2;
|
| 1192 |
-
maxY = center.y + size.y / 2;
|
| 1193 |
-
maxZ = center.z + size.z / 2;
|
| 1194 |
-
}
|
| 1195 |
|
| 1196 |
-
|
| 1197 |
-
|
| 1198 |
-
|
| 1199 |
-
|
|
|
|
| 1200 |
|
| 1201 |
-
|
| 1202 |
-
|
| 1203 |
-
|
| 1204 |
-
|
| 1205 |
-
|
| 1206 |
-
new THREE.Vector3(minX, maxY, minZ), // 3
|
| 1207 |
-
new THREE.Vector3(minX, minY, maxZ), // 4
|
| 1208 |
-
new THREE.Vector3(maxX, minY, maxZ), // 5
|
| 1209 |
-
new THREE.Vector3(maxX, maxY, maxZ), // 6
|
| 1210 |
-
new THREE.Vector3(minX, maxY, maxZ) // 7
|
| 1211 |
-
];
|
| 1212 |
|
| 1213 |
-
|
| 1214 |
-
|
| 1215 |
-
|
| 1216 |
-
|
| 1217 |
-
|
| 1218 |
-
);
|
| 1219 |
|
|
|
|
|
|
|
| 1220 |
const edges = new THREE.EdgesGeometry(geometry);
|
| 1221 |
const material = new THREE.LineBasicMaterial({ color: 0x00ff00, linewidth: 2 });
|
| 1222 |
const boxHelper = new THREE.LineSegments(edges, material);
|
| 1223 |
|
| 1224 |
-
//
|
| 1225 |
-
|
| 1226 |
-
|
| 1227 |
-
(minY + maxY) / 2,
|
| 1228 |
-
(minZ + maxZ) / 2
|
| 1229 |
-
);
|
| 1230 |
|
| 1231 |
scene.add(boxHelper);
|
| 1232 |
|
| 1233 |
-
console.log('[
|
| 1234 |
|
| 1235 |
return boxHelper;
|
| 1236 |
}
|
| 1237 |
|
| 1238 |
|
| 1239 |
// ========================================
|
| 1240 |
-
//
|
| 1241 |
-
//
|
| 1242 |
-
|
| 1243 |
-
/*
|
| 1244 |
-
// ไพ1: min/maxๅฝขๅผ
|
| 1245 |
-
const box1 = createWorldSpaceBox(
|
| 1246 |
-
{
|
| 1247 |
-
min: { x: 0, y: 0, z: 0 },
|
| 1248 |
-
max: { x: 1, y: 1, z: 1 }
|
| 1249 |
-
},
|
| 1250 |
-
scene,
|
| 1251 |
-
camera
|
| 1252 |
-
);
|
| 1253 |
-
|
| 1254 |
-
// ไพ2: center/sizeๅฝขๅผ
|
| 1255 |
-
const box2 = createWorldSpaceBox(
|
| 1256 |
-
{
|
| 1257 |
-
center: { x: 0.5, y: 0.5, z: 0.5 },
|
| 1258 |
-
size: { x: 1, y: 1, z: 1 }
|
| 1259 |
-
},
|
| 1260 |
-
scene,
|
| 1261 |
-
camera
|
| 1262 |
-
);
|
| 1263 |
-
|
| 1264 |
-
// ไพ3: PLYใใผใฟใฎๅฎ้ใฎ็ฏๅฒใซๅบใฅใ
|
| 1265 |
-
const box3 = createWorldSpaceBox(
|
| 1266 |
-
{
|
| 1267 |
-
min: { x: minX, y: minY, z: minZ },
|
| 1268 |
-
max: { x: maxX, y: maxY, z: maxZ }
|
| 1269 |
-
},
|
| 1270 |
-
scene,
|
| 1271 |
-
camera
|
| 1272 |
-
);
|
| 1273 |
-
*/
|
| 1274 |
-
|
| 1275 |
-
|
| 1276 |
-
// ========================================
|
| 1277 |
-
// ไฟฎๆญฃ4: filterSplatsByBox ใไธ็ๅบงๆจใใผในใซไฟฎๆญฃ
|
| 1278 |
// ========================================
|
| 1279 |
|
| 1280 |
/**
|
| 1281 |
-
*
|
| 1282 |
-
* @param {Object} plyData - PLYใใผใฟ๏ผ
|
| 1283 |
-
* @param {Object}
|
| 1284 |
-
* @param {Object} boxMax - { x, y, z } ใใใฏในใฎๆๅคง็น
|
| 1285 |
* @returns {Array} ใใฃใซใฟใชใณใฐใใใ้ ็น้
ๅ
|
| 1286 |
*/
|
| 1287 |
-
function
|
| 1288 |
-
console.log('[
|
| 1289 |
-
console.log('
|
| 1290 |
-
console.log('
|
|
|
|
| 1291 |
console.log(' Total vertices:', plyData.vertices.length);
|
| 1292 |
|
| 1293 |
-
const
|
|
|
|
|
|
|
|
|
|
| 1294 |
return (
|
| 1295 |
-
vertex.x >=
|
| 1296 |
-
vertex.y >=
|
| 1297 |
-
vertex.z >=
|
| 1298 |
);
|
| 1299 |
});
|
| 1300 |
|
| 1301 |
-
|
| 1302 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1303 |
|
| 1304 |
-
return
|
| 1305 |
}
|
| 1306 |
|
| 1307 |
|
| 1308 |
// ========================================
|
| 1309 |
-
//
|
| 1310 |
// ========================================
|
| 1311 |
|
| 1312 |
-
|
| 1313 |
-
|
| 1314 |
-
|
| 1315 |
-
|
| 1316 |
-
|
| 1317 |
-
|
| 1318 |
-
|
| 1319 |
-
|
| 1320 |
-
|
| 1321 |
-
|
| 1322 |
-
maxY = Math.max(maxY, v.y);
|
| 1323 |
-
maxZ = Math.max(maxZ, v.z);
|
| 1324 |
-
});
|
| 1325 |
|
| 1326 |
-
|
| 1327 |
-
|
| 1328 |
-
|
| 1329 |
-
});
|
| 1330 |
|
| 1331 |
-
|
| 1332 |
-
|
| 1333 |
-
|
| 1334 |
-
|
| 1335 |
-
|
| 1336 |
-
|
| 1337 |
-
|
| 1338 |
-
|
| 1339 |
-
const boxHelper = createWorldSpaceBox(
|
| 1340 |
-
{
|
| 1341 |
-
center: { x: centerX, y: centerY, z: centerZ },
|
| 1342 |
-
size: { x: sizeX, y: sizeY, z: sizeZ }
|
| 1343 |
-
},
|
| 1344 |
-
scene,
|
| 1345 |
-
camera
|
| 1346 |
-
);
|
| 1347 |
-
|
| 1348 |
-
// 3. ใใใฏในๅ
ใฎในใใฉใใใใใฃใซใฟใชใณใฐ
|
| 1349 |
-
const filteredVertices = filterSplatsByWorldBox(
|
| 1350 |
-
plyData,
|
| 1351 |
-
{
|
| 1352 |
-
x: centerX - sizeX / 2,
|
| 1353 |
-
y: centerY - sizeY / 2,
|
| 1354 |
-
z: centerZ - sizeZ / 2
|
| 1355 |
-
},
|
| 1356 |
-
{
|
| 1357 |
-
x: centerX + sizeX / 2,
|
| 1358 |
-
y: centerY + sizeY / 2,
|
| 1359 |
-
z: centerZ + sizeZ / 2
|
| 1360 |
-
}
|
| 1361 |
-
);
|
| 1362 |
|
| 1363 |
-
|
| 1364 |
-
camera.position.set(
|
| 1365 |
-
centerX,
|
| 1366 |
-
centerY + (maxY - minY) * 2,
|
| 1367 |
-
centerZ + (maxZ - minZ) * 3
|
| 1368 |
-
);
|
| 1369 |
-
camera.lookAt(centerX, centerY, centerZ);
|
| 1370 |
-
camera.updateProjectionMatrix();
|
| 1371 |
|
| 1372 |
-
|
| 1373 |
-
console.log('[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1374 |
|
| 1375 |
return {
|
| 1376 |
-
boxHelper,
|
| 1377 |
filteredVertices,
|
| 1378 |
-
|
|
|
|
| 1379 |
};
|
| 1380 |
}
|
| 1381 |
|
| 1382 |
|
| 1383 |
-
|
| 1384 |
-
|
|
|
|
| 1385 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1386 |
|
|
|
|
|
|
|
| 1387 |
|
|
|
|
| 1388 |
|
| 1389 |
|
| 1390 |
// ========================================
|
| 1391 |
-
//
|
|
|
|
| 1392 |
// ========================================
|
| 1393 |
-
console.log('[preprocessManual] Step 4: Calculating bounding box...');
|
| 1394 |
|
| 1395 |
-
|
| 1396 |
-
|
| 1397 |
-
|
| 1398 |
-
|
| 1399 |
-
|
| 1400 |
-
|
| 1401 |
-
|
| 1402 |
-
|
| 1403 |
-
|
| 1404 |
-
|
| 1405 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1406 |
}
|
| 1407 |
|
| 1408 |
-
console.log('[preprocessManual] Bounding box calculated:', {
|
| 1409 |
-
min: { x: minX.toFixed(3), y: minY.toFixed(3), z: minZ.toFixed(3) },
|
| 1410 |
-
max: { x: maxX.toFixed(3), y: maxY.toFixed(3), z: maxZ.toFixed(3) },
|
| 1411 |
-
size: {
|
| 1412 |
-
x: (maxX - minX).toFixed(3),
|
| 1413 |
-
y: (maxY - minY).toFixed(3),
|
| 1414 |
-
z: (maxZ - minZ).toFixed(3)
|
| 1415 |
-
}
|
| 1416 |
-
});
|
| 1417 |
|
| 1418 |
-
////////////////
|
| 1419 |
-
console.log('[preprocessManual] ===== AUTO-ALIGNMENT COMPLETE =====');
|
| 1420 |
|
|
|
|
| 1421 |
|
| 1422 |
/////////////////////////////////////////15:01
|
| 1423 |
// GSใฎๅๆ่กจ็คบ
|
|
|
|
| 1109 |
// ใใใใฐ็: PLYไธญๅฟๅ๏ผLine 1107-1330ใ็ฝฎใๆใ๏ผ
|
| 1110 |
// ๅในใใใใง้
ๅใฎๅ็
งใ็ขบ่ช
|
| 1111 |
// ========================================
|
| 1112 |
+
///// Line 1113-1419 ใไปฅไธใซ็ฝฎใๆใ ///// Line 1113-1419 ใไปฅไธใซ็ฝฎใๆใ
|
| 1113 |
|
|
|
|
| 1114 |
|
| 1115 |
+
// ========================================
|
| 1116 |
+
// 1. PLYใใซใกใฉๅบงๆจ็ณปใฎใพใพใซใใ
|
| 1117 |
+
// Line 1113-1419 ใไปฅไธใซ็ฝฎใๆใ
|
| 1118 |
+
// ========================================
|
| 1119 |
+
|
| 1120 |
+
console.log('[preprocessManual] ===== PLY DATA LOADED =====');
|
| 1121 |
+
console.log('[preprocessManual] PLY data is in CAMERA coordinate space');
|
| 1122 |
+
console.log(' Total vertices:', plyData.vertices.length);
|
| 1123 |
+
|
| 1124 |
+
// โญ ้่ฆ: PLYใฏๆขใซใซใกใฉๅบงๆจ็ณปใชใฎใงใใใฎใพใพไฝฟ็จ
|
| 1125 |
+
// ไธญๅฟๅใ็งปๅใไธๅใใชใ
|
| 1126 |
+
|
| 1127 |
+
// ็ตฑ่จๆ
ๅ ฑใฎใฟ่จ็ฎ
|
| 1128 |
+
let minX = Infinity, minY = Infinity, minZ = Infinity;
|
| 1129 |
+
let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;
|
| 1130 |
+
|
| 1131 |
+
for (let i = 0; i < plyData.vertices.length; i++) {
|
| 1132 |
+
const v = plyData.vertices[i];
|
| 1133 |
+
minX = Math.min(minX, v.x);
|
| 1134 |
+
minY = Math.min(minY, v.y);
|
| 1135 |
+
minZ = Math.min(minZ, v.z);
|
| 1136 |
+
maxX = Math.max(maxX, v.x);
|
| 1137 |
+
maxY = Math.max(maxY, v.y);
|
| 1138 |
+
maxZ = Math.max(maxZ, v.z);
|
| 1139 |
+
}
|
| 1140 |
+
|
| 1141 |
+
console.log('[preprocessManual] PLY bounds (CAMERA space):');
|
| 1142 |
+
console.log(' Min:', { x: minX.toFixed(3), y: minY.toFixed(3), z: minZ.toFixed(3) });
|
| 1143 |
+
console.log(' Max:', { x: maxX.toFixed(3), y: maxY.toFixed(3), z: maxZ.toFixed(3) });
|
| 1144 |
+
console.log(' Center:', {
|
| 1145 |
+
x: ((minX + maxX) / 2).toFixed(3),
|
| 1146 |
+
y: ((minY + maxY) / 2).toFixed(3),
|
| 1147 |
+
z: ((minZ + maxZ) / 2).toFixed(3)
|
| 1148 |
});
|
|
|
|
| 1149 |
|
| 1150 |
+
console.log('[preprocessManual] โ PLY coordinates preserved (CAMERA space)');
|
|
|
|
| 1151 |
|
| 1152 |
|
| 1153 |
// ========================================
|
| 1154 |
+
// 2. ไธ็ๅบงๆจโใซใกใฉๅบงๆจใฎๅคๆ้ขๆฐ
|
| 1155 |
// ========================================
|
| 1156 |
|
| 1157 |
/**
|
| 1158 |
+
* ไธ็ๅบงๆจใใซใกใฉๅบงๆจใซๅคๆ
|
| 1159 |
* @param {THREE.Vector3} worldPos - ไธ็ๅบงๆจใฎไฝ็ฝฎ
|
| 1160 |
* @param {THREE.Camera} camera - ใซใกใฉใชใใธใงใฏใ
|
| 1161 |
+
* @returns {THREE.Vector3} ใซใกใฉๅบงๆจใงใฎไฝ็ฝฎ
|
| 1162 |
*/
|
| 1163 |
function worldToCameraSpace(worldPos, camera) {
|
| 1164 |
const cameraPos = worldPos.clone();
|
| 1165 |
|
| 1166 |
+
// ใซใกใฉใฎใใฅใผ่กๅใๆดๆฐ
|
| 1167 |
camera.updateMatrixWorld();
|
| 1168 |
+
|
| 1169 |
+
// ไธ็ๅบงๆจโใซใกใฉๅบงๆจใฎๅคๆ
|
| 1170 |
+
// ใใฅใผ่กๅ = ใซใกใฉใฎmatrixWorldInverse
|
| 1171 |
+
cameraPos.applyMatrix4(camera.matrixWorldInverse);
|
| 1172 |
|
| 1173 |
return cameraPos;
|
| 1174 |
}
|
| 1175 |
|
| 1176 |
/**
|
| 1177 |
+
* ไธ็ๅบงๆจใฎBOXใใซใกใฉๅบงๆจใฎBOXใซๅคๆ
|
| 1178 |
+
* @param {Object} worldBox - { min: {x,y,z}, max: {x,y,z} }
|
| 1179 |
* @param {THREE.Camera} camera - ใซใกใฉใชใใธใงใฏใ
|
| 1180 |
+
* @returns {Object} ใซใกใฉๅบงๆจใฎBOX { min: {x,y,z}, max: {x,y,z} }
|
| 1181 |
*/
|
| 1182 |
+
function transformBoxToCameraSpace(worldBox, camera) {
|
| 1183 |
+
const { min, max } = worldBox;
|
| 1184 |
+
|
| 1185 |
+
// 8้ ็นใไธ็ๅบงๆจใงๅฎ็พฉ
|
| 1186 |
+
const vertices = [
|
| 1187 |
+
new THREE.Vector3(min.x, min.y, min.z),
|
| 1188 |
+
new THREE.Vector3(max.x, min.y, min.z),
|
| 1189 |
+
new THREE.Vector3(max.x, max.y, min.z),
|
| 1190 |
+
new THREE.Vector3(min.x, max.y, min.z),
|
| 1191 |
+
new THREE.Vector3(min.x, min.y, max.z),
|
| 1192 |
+
new THREE.Vector3(max.x, min.y, max.z),
|
| 1193 |
+
new THREE.Vector3(max.x, max.y, max.z),
|
| 1194 |
+
new THREE.Vector3(min.x, max.y, max.z)
|
| 1195 |
+
];
|
| 1196 |
|
| 1197 |
+
// ๅ้ ็นใใซใกใฉๅบงๆจใซๅคๆ
|
| 1198 |
+
const cameraVertices = vertices.map(v => worldToCameraSpace(v, camera));
|
| 1199 |
|
| 1200 |
+
// ใซใกใฉๅบงๆจใงใฎๆฐใใAABB๏ผ่ปธไธฆ่กๅข็ใใใฏใน๏ผใ่จ็ฎ
|
| 1201 |
+
let cMinX = Infinity, cMinY = Infinity, cMinZ = Infinity;
|
| 1202 |
+
let cMaxX = -Infinity, cMaxY = -Infinity, cMaxZ = -Infinity;
|
| 1203 |
+
|
| 1204 |
+
cameraVertices.forEach(v => {
|
| 1205 |
+
cMinX = Math.min(cMinX, v.x);
|
| 1206 |
+
cMinY = Math.min(cMinY, v.y);
|
| 1207 |
+
cMinZ = Math.min(cMinZ, v.z);
|
| 1208 |
+
cMaxX = Math.max(cMaxX, v.x);
|
| 1209 |
+
cMaxY = Math.max(cMaxY, v.y);
|
| 1210 |
+
cMaxZ = Math.max(cMaxZ, v.z);
|
| 1211 |
+
});
|
| 1212 |
+
|
| 1213 |
+
return {
|
| 1214 |
+
min: { x: cMinX, y: cMinY, z: cMinZ },
|
| 1215 |
+
max: { x: cMaxX, y: cMaxY, z: cMaxZ }
|
| 1216 |
+
};
|
| 1217 |
}
|
| 1218 |
|
| 1219 |
+
console.log('[preprocessManual] โ Coordinate transformation functions defined');
|
| 1220 |
+
|
| 1221 |
|
| 1222 |
// ========================================
|
| 1223 |
+
// 3. BOXใใซใกใฉๅบงๆจ็ณปใงไฝๆใป่กจ็คบ
|
|
|
|
| 1224 |
// ========================================
|
| 1225 |
|
| 1226 |
/**
|
| 1227 |
+
* ใซใกใฉๅบงๆจ็ณปใงBOXใไฝๆ
|
| 1228 |
+
* @param {Object} cameraBox - { min: {x,y,z}, max: {x,y,z} } ใซใกใฉๅบงๆจ
|
| 1229 |
* @param {THREE.Scene} scene - Three.jsใทใผใณ
|
| 1230 |
+
* @returns {THREE.LineSegments} BOXใชใใธใงใฏใ
|
| 1231 |
*/
|
| 1232 |
+
function createCameraSpaceBox(cameraBox, scene) {
|
| 1233 |
+
const { min, max } = cameraBox;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1234 |
|
| 1235 |
+
const size = {
|
| 1236 |
+
x: max.x - min.x,
|
| 1237 |
+
y: max.y - min.y,
|
| 1238 |
+
z: max.z - min.z
|
| 1239 |
+
};
|
| 1240 |
|
| 1241 |
+
const center = {
|
| 1242 |
+
x: (min.x + max.x) / 2,
|
| 1243 |
+
y: (min.y + max.y) / 2,
|
| 1244 |
+
z: (min.z + max.z) / 2
|
| 1245 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1246 |
|
| 1247 |
+
console.log('[createCameraSpaceBox] Creating box in CAMERA space:');
|
| 1248 |
+
console.log(' Min:', min);
|
| 1249 |
+
console.log(' Max:', max);
|
| 1250 |
+
console.log(' Center:', center);
|
| 1251 |
+
console.log(' Size:', size);
|
|
|
|
| 1252 |
|
| 1253 |
+
// BOXใธใชใกใใชใไฝๆ
|
| 1254 |
+
const geometry = new THREE.BoxGeometry(size.x, size.y, size.z);
|
| 1255 |
const edges = new THREE.EdgesGeometry(geometry);
|
| 1256 |
const material = new THREE.LineBasicMaterial({ color: 0x00ff00, linewidth: 2 });
|
| 1257 |
const boxHelper = new THREE.LineSegments(edges, material);
|
| 1258 |
|
| 1259 |
+
// โญ ้่ฆ: ใซใกใฉๅบงๆจ็ณปใง้
็ฝฎ
|
| 1260 |
+
// ใซใกใฉๅบงๆจ็ณป = ใญใผใซใซๅบงๆจ็ณปใชใฎใงใใทใผใณใซ็ดๆฅ่ฟฝๅ
|
| 1261 |
+
boxHelper.position.set(center.x, center.y, center.z);
|
|
|
|
|
|
|
|
|
|
| 1262 |
|
| 1263 |
scene.add(boxHelper);
|
| 1264 |
|
| 1265 |
+
console.log('[createCameraSpaceBox] โ Box added in camera space');
|
| 1266 |
|
| 1267 |
return boxHelper;
|
| 1268 |
}
|
| 1269 |
|
| 1270 |
|
| 1271 |
// ========================================
|
| 1272 |
+
// 4. ใใฃใซใฟใชใณใฐ้ขๆฐ๏ผใซใกใฉๅบงๆจ็ณป๏ผ
|
| 1273 |
+
// Line 527-742 ใไปฅไธใซ็ฝฎใๆใ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1274 |
// ========================================
|
| 1275 |
|
| 1276 |
/**
|
| 1277 |
+
* ใซใกใฉๅบงๆจ็ณปใฎBOXๅ
ใฎในใใฉใใใใใฃใซใฟใชใณใฐ
|
| 1278 |
+
* @param {Object} plyData - PLYใใผใฟ๏ผcamera coordinates๏ผ
|
| 1279 |
+
* @param {Object} cameraBox - { min: {x,y,z}, max: {x,y,z} } ใซใกใฉๅบงๆจ
|
|
|
|
| 1280 |
* @returns {Array} ใใฃใซใฟใชใณใฐใใใ้ ็น้
ๅ
|
| 1281 |
*/
|
| 1282 |
+
function filterSplatsByCameraBox(plyData, cameraBox) {
|
| 1283 |
+
console.log('[filterSplatsByCameraBox] ===== FILTERING START =====');
|
| 1284 |
+
console.log('[filterSplatsByCameraBox] CAMERA-space box:');
|
| 1285 |
+
console.log(' Min:', cameraBox.min);
|
| 1286 |
+
console.log(' Max:', cameraBox.max);
|
| 1287 |
console.log(' Total vertices:', plyData.vertices.length);
|
| 1288 |
|
| 1289 |
+
const { min, max } = cameraBox;
|
| 1290 |
+
|
| 1291 |
+
// โญ PLYใใซใกใฉๅบงๆจใBOXใใซใกใฉๅบงๆจใชใฎใงใใทใณใใซใช็ฏๅฒใใงใใฏ
|
| 1292 |
+
const filteredVertices = plyData.vertices.filter(vertex => {
|
| 1293 |
return (
|
| 1294 |
+
vertex.x >= min.x && vertex.x <= max.x &&
|
| 1295 |
+
vertex.y >= min.y && vertex.y <= max.y &&
|
| 1296 |
+
vertex.z >= min.z && vertex.z <= max.z
|
| 1297 |
);
|
| 1298 |
});
|
| 1299 |
|
| 1300 |
+
const retentionRate = (filteredVertices.length / plyData.vertices.length * 100).toFixed(1);
|
| 1301 |
+
|
| 1302 |
+
console.log('[filterSplatsByCameraBox] ===== FILTERING COMPLETE =====');
|
| 1303 |
+
console.log(' Filtered:', filteredVertices.length, '/', plyData.vertices.length);
|
| 1304 |
+
console.log(' Retention rate:', retentionRate, '%');
|
| 1305 |
+
|
| 1306 |
+
if (filteredVertices.length > 0) {
|
| 1307 |
+
let fMinX = Infinity, fMinY = Infinity, fMinZ = Infinity;
|
| 1308 |
+
let fMaxX = -Infinity, fMaxY = -Infinity, fMaxZ = -Infinity;
|
| 1309 |
+
|
| 1310 |
+
filteredVertices.forEach(v => {
|
| 1311 |
+
fMinX = Math.min(fMinX, v.x);
|
| 1312 |
+
fMinY = Math.min(fMinY, v.y);
|
| 1313 |
+
fMinZ = Math.min(fMinZ, v.z);
|
| 1314 |
+
fMaxX = Math.max(fMaxX, v.x);
|
| 1315 |
+
fMaxY = Math.max(fMaxY, v.y);
|
| 1316 |
+
fMaxZ = Math.max(fMaxZ, v.z);
|
| 1317 |
+
});
|
| 1318 |
+
|
| 1319 |
+
console.log('[filterSplatsByCameraBox] Filtered bounds (camera space):');
|
| 1320 |
+
console.log(' X:', fMinX.toFixed(3), 'to', fMaxX.toFixed(3));
|
| 1321 |
+
console.log(' Y:', fMinY.toFixed(3), 'to', fMaxY.toFixed(3));
|
| 1322 |
+
console.log(' Z:', fMinZ.toFixed(3), 'to', fMaxZ.toFixed(3));
|
| 1323 |
+
}
|
| 1324 |
+
|
| 1325 |
+
if (filteredVertices.length === 0) {
|
| 1326 |
+
console.error('[filterSplatsByCameraBox] โ No vertices in box!');
|
| 1327 |
+
}
|
| 1328 |
|
| 1329 |
+
return filteredVertices;
|
| 1330 |
}
|
| 1331 |
|
| 1332 |
|
| 1333 |
// ========================================
|
| 1334 |
+
// 5. ็ตฑๅๅฆ็๏ผไธ็ๅบงๆจใฎBOX โ ใใฃใซใฟใชใณใฐ
|
| 1335 |
// ========================================
|
| 1336 |
|
| 1337 |
+
/**
|
| 1338 |
+
* ไธ็ๅบงๆจใฎBOXใงPLYใใใฃใซใฟใชใณใฐ๏ผๅฎๅ
จใชๅฆ็๏ผ
|
| 1339 |
+
* @param {Object} plyData - PLYใใผใฟ๏ผcamera coordinates๏ผ
|
| 1340 |
+
* @param {Object} worldBox - ไธ็ๅบงๆจใฎBOX { min: {x,y,z}, max: {x,y,z} }
|
| 1341 |
+
* @param {THREE.Camera} camera - ใซใกใฉใชใใธใงใฏใ
|
| 1342 |
+
* @param {THREE.Scene} scene - Three.jsใทใผใณ
|
| 1343 |
+
* @returns {Object} { filteredVertices: Array, cameraBox: Object, boxHelper: Object }
|
| 1344 |
+
*/
|
| 1345 |
+
function filterWithWorldBox(plyData, worldBox, camera, scene) {
|
| 1346 |
+
console.log('[filterWithWorldBox] ===== COMPLETE FILTERING PROCESS =====');
|
|
|
|
|
|
|
|
|
|
| 1347 |
|
| 1348 |
+
// Step 1: ไธ็ๅบงๆจใฎBOXใใซใกใฉๅบงๆจใซๅคๆ
|
| 1349 |
+
console.log('[filterWithWorldBox] Step 1: Transform box to camera space');
|
| 1350 |
+
console.log(' World box:', worldBox);
|
|
|
|
| 1351 |
|
| 1352 |
+
const cameraBox = transformBoxToCameraSpace(worldBox, camera);
|
| 1353 |
+
|
| 1354 |
+
console.log('[filterWithWorldBox] โ Transformed to camera space:', cameraBox);
|
| 1355 |
+
|
| 1356 |
+
// Step 2: ใซใกใฉๅบงๆจใงBOXใ่กจ็คบ
|
| 1357 |
+
console.log('[filterWithWorldBox] Step 2: Display box in camera space');
|
| 1358 |
+
|
| 1359 |
+
const boxHelper = createCameraSpaceBox(cameraBox, scene);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1360 |
|
| 1361 |
+
console.log('[filterWithWorldBox] โ Box displayed');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1362 |
|
| 1363 |
+
// Step 3: ใซใกใฉๅบงๆจใงใใฃใซใฟใชใณใฐ
|
| 1364 |
+
console.log('[filterWithWorldBox] Step 3: Filter splats in camera space');
|
| 1365 |
+
|
| 1366 |
+
const filteredVertices = filterSplatsByCameraBox(plyData, cameraBox);
|
| 1367 |
+
|
| 1368 |
+
console.log('[filterWithWorldBox] โ Filtering complete:', filteredVertices.length, 'vertices');
|
| 1369 |
+
|
| 1370 |
+
console.log('[filterWithWorldBox] ===== PROCESS COMPLETE =====');
|
| 1371 |
|
| 1372 |
return {
|
|
|
|
| 1373 |
filteredVertices,
|
| 1374 |
+
cameraBox,
|
| 1375 |
+
boxHelper
|
| 1376 |
};
|
| 1377 |
}
|
| 1378 |
|
| 1379 |
|
| 1380 |
+
// ========================================
|
| 1381 |
+
// ไฝฟ็จไพ: ไธ็ๅบงๆจ (0,0,0) ใใ (1,1,1) ใฎBOXใงใใฃใซใฟใชใณใฐ
|
| 1382 |
+
// ========================================
|
| 1383 |
|
| 1384 |
+
// UIใใๅๅพใใไธ็ๅบงๆจใฎBOX
|
| 1385 |
+
const worldBox = {
|
| 1386 |
+
min: { x: 0, y: 0, z: 0 },
|
| 1387 |
+
max: { x: 1, y: 1, z: 1 }
|
| 1388 |
+
};
|
| 1389 |
|
| 1390 |
+
// ๅฎๅ
จใชๅฆ็
|
| 1391 |
+
const result = filterWithWorldBox(plyData, worldBox, camera, scene);
|
| 1392 |
|
| 1393 |
+
console.log('Result:', result.filteredVertices.length, 'vertices filtered');
|
| 1394 |
|
| 1395 |
|
| 1396 |
// ========================================
|
| 1397 |
+
// UI็ตฑๅ็: confirm-box-btn ใคใใณใใชในใใผ
|
| 1398 |
+
// Line 1608ไป่ฟใไปฅไธใซ็ฝฎใๆใ
|
| 1399 |
// ========================================
|
|
|
|
| 1400 |
|
| 1401 |
+
const confirmBoxBtn = document.getElementById('confirm-box-btn');
|
| 1402 |
+
if (confirmBoxBtn) {
|
| 1403 |
+
confirmBoxBtn.addEventListener('click', async () => {
|
| 1404 |
+
console.log('\n\n');
|
| 1405 |
+
console.log('โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ');
|
| 1406 |
+
console.log(' CONFIRM BOX BUTTON CLICKED');
|
| 1407 |
+
console.log('โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ');
|
| 1408 |
+
|
| 1409 |
+
// โญ Step 1: UIใใไธ็ๅบงๆจใฎBOX่จญๅฎใๅๅพ
|
| 1410 |
+
const worldBoxSize = {
|
| 1411 |
+
x: parseFloat(document.getElementById('box-x-step0').value),
|
| 1412 |
+
y: parseFloat(document.getElementById('box-y-step0').value),
|
| 1413 |
+
z: parseFloat(document.getElementById('box-z-step0').value)
|
| 1414 |
+
};
|
| 1415 |
+
|
| 1416 |
+
const worldBoxPosition = {
|
| 1417 |
+
x: parseFloat(document.getElementById('box-x-pos-step0').value),
|
| 1418 |
+
y: parseFloat(document.getElementById('box-y-pos-step0').value),
|
| 1419 |
+
z: parseFloat(document.getElementById('box-z-pos-step0').value)
|
| 1420 |
+
};
|
| 1421 |
+
|
| 1422 |
+
// โญ ไธ็ๅบงๆจใงใฎBOX็ฏๅฒใ่จ็ฎ
|
| 1423 |
+
const worldBox = {
|
| 1424 |
+
min: {
|
| 1425 |
+
x: worldBoxPosition.x - worldBoxSize.x / 2,
|
| 1426 |
+
y: worldBoxPosition.y - worldBoxSize.y / 2,
|
| 1427 |
+
z: worldBoxPosition.z - worldBoxSize.z / 2
|
| 1428 |
+
},
|
| 1429 |
+
max: {
|
| 1430 |
+
x: worldBoxPosition.x + worldBoxSize.x / 2,
|
| 1431 |
+
y: worldBoxPosition.y + worldBoxSize.y / 2,
|
| 1432 |
+
z: worldBoxPosition.z + worldBoxSize.z / 2
|
| 1433 |
+
}
|
| 1434 |
+
};
|
| 1435 |
+
|
| 1436 |
+
console.log('[CONFIRM] World box (from UI):', worldBox);
|
| 1437 |
+
|
| 1438 |
+
// โญ Step 2: ไธ็ๅบงๆจBOXใใซใกใฉๅบงๆจใซๅคๆ
|
| 1439 |
+
console.log('[CONFIRM] Transforming box to camera space...');
|
| 1440 |
+
|
| 1441 |
+
const cameraBox = transformBoxToCameraSpace(worldBox, camera);
|
| 1442 |
+
|
| 1443 |
+
console.log('[CONFIRM] Camera box (transformed):', cameraBox);
|
| 1444 |
+
|
| 1445 |
+
// โญ Step 3: ใซใกใฉๅบงๆจใงBOXใ่กจ็คบ
|
| 1446 |
+
console.log('[CONFIRM] Displaying box in camera space...');
|
| 1447 |
+
|
| 1448 |
+
ui.removeBoundingBox(); // ๅคใBOXใๅ้ค
|
| 1449 |
+
const boxHelper = createCameraSpaceBox(cameraBox, scene);
|
| 1450 |
+
|
| 1451 |
+
// โญ Step 4: ใซใกใฉๅบงๆจใงใใฃใซใฟใชใณใฐ
|
| 1452 |
+
console.log('[CONFIRM] Filtering splats in camera space...');
|
| 1453 |
+
|
| 1454 |
+
const filteredVertices = filterSplatsByCameraBox(plyData, cameraBox);
|
| 1455 |
+
|
| 1456 |
+
// โญ ใจใฉใผใใงใใฏ
|
| 1457 |
+
if (filteredVertices.length === 0) {
|
| 1458 |
+
console.error('[CONFIRM] โ No splats found in the box!');
|
| 1459 |
+
alert('โ ๏ธ No splats found in the box!\n\nPlease adjust the box.');
|
| 1460 |
+
ui.showPositionAdjustment();
|
| 1461 |
+
return;
|
| 1462 |
+
}
|
| 1463 |
+
|
| 1464 |
+
if (filteredVertices.length < 10) {
|
| 1465 |
+
console.warn('[CONFIRM] โ ๏ธ Only', filteredVertices.length, 'splats found');
|
| 1466 |
+
const proceed = confirm(
|
| 1467 |
+
`Only ${filteredVertices.length} splats found.\n\nThis is very few. Continue anyway?`
|
| 1468 |
+
);
|
| 1469 |
+
if (!proceed) {
|
| 1470 |
+
ui.showPositionAdjustment();
|
| 1471 |
+
return;
|
| 1472 |
+
}
|
| 1473 |
+
}
|
| 1474 |
+
|
| 1475 |
+
console.log('[CONFIRM] โ Filtered', filteredVertices.length, 'vertices');
|
| 1476 |
+
console.log('โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ');
|
| 1477 |
+
console.log(' BOX FILTERING COMPLETE');
|
| 1478 |
+
console.log('โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ');
|
| 1479 |
+
|
| 1480 |
+
// โญ ไปฅ้ใฏๅ
ใฎใณใผใ๏ผSTEP 5ไปฅ้๏ผใจๅๆง
|
| 1481 |
+
// ใใฃใซใฟใชใณใฐๅพใฎPLYไฟๅญใGSๅ่ชญใฟ่พผใฟใVRM่ชญใฟ่พผใฟ็ญ...
|
| 1482 |
+
});
|
| 1483 |
}
|
| 1484 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1485 |
|
|
|
|
|
|
|
| 1486 |
|
| 1487 |
+
///// Line 1113-1419 ใไปฅไธใซ็ฝฎใๆใ ///// Line 1113-1419 ใไปฅไธใซ็ฝฎใๆใ
|
| 1488 |
|
| 1489 |
/////////////////////////////////////////15:01
|
| 1490 |
// GSใฎๅๆ่กจ็คบ
|