Upload 2 files
Browse files- log.md +290 -0
- preprocess_manual.js +407 -2
log.md
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Live reload enabled.
|
| 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
|
| 6 |
+
main.js:52 [MAIN] Initial paths - gsPath: undefined gvrmPath: undefined
|
| 7 |
+
main.js:55 [MAIN] No paths in URL, showing select UI
|
| 8 |
+
main.js:66 [MAIN] Elements check:
|
| 9 |
+
main.js:67 - selectContainer: true
|
| 10 |
+
main.js:68 - manualModeButton: true
|
| 11 |
+
main.js:69 - manualFileInput: true
|
| 12 |
+
main.js:117 [MAIN] Setting up file load promise
|
| 13 |
+
main.js:172 [MAIN] Setting up manual mode listeners
|
| 14 |
+
main.js:229 [MAIN] Manual mode listeners set up successfully
|
| 15 |
+
main.js:259 [MAIN] Waiting for file load promise...
|
| 16 |
+
main.js:175 [MAIN] ===== Manual mode button clicked! =====
|
| 17 |
+
main.js:178 [MAIN] Opening manual file input...
|
| 18 |
+
main.js:175 [MAIN] ===== Manual mode button clicked! =====
|
| 19 |
+
main.js:178 [MAIN] Opening manual file input...
|
| 20 |
+
main.js:184 [MAIN] ===== Manual file input changed! =====
|
| 21 |
+
main.js:186 [MAIN] File object: File
|
| 22 |
+
main.js:190 [MAIN] Manual file selected: fountain_trim9.ply Extension: ply
|
| 23 |
+
main.js:198 [MAIN] Reading manual file...
|
| 24 |
+
main.js:201 [MAIN] Manual file read complete, size: 57407083
|
| 25 |
+
main.js:209 [MAIN] Manual mode file loaded: fountain_trim9.ply
|
| 26 |
+
main.js:210 [MAIN] gsPath: blob:http://127.0.0.1:5500/513a1be2-32e6-405e-aec0-47de526c5c35
|
| 27 |
+
main.js:211 [MAIN] gsFileName: fountain_trim9.ply
|
| 28 |
+
main.js:110 [MAIN] Hiding select UI
|
| 29 |
+
main.js:215 [MAIN] ===== Resolving with MANUAL MODE =====
|
| 30 |
+
main.js:261 [MAIN] File load promise resolved: Object
|
| 31 |
+
main.js:271 [MAIN] setupPathsFromUrlOrSelect returned: Object
|
| 32 |
+
main.js:277 [MAIN] After pathResult:
|
| 33 |
+
main.js:278 - gsPath: blob:http://127.0.0.1:5500/513a1be2-32e6-405e-aec0-47de526c5c35
|
| 34 |
+
main.js:279 - gvrmPath: undefined
|
| 35 |
+
main.js:280 - isManualMode: true
|
| 36 |
+
main.js:283 [MAIN] Initializing renderer...
|
| 37 |
+
main.js:289 [MAIN] Initializing camera...
|
| 38 |
+
main.js:316 [MAIN] Initializing scene...
|
| 39 |
+
main.js:323 [MAIN] Three.js initialization complete
|
| 40 |
+
main.js:506 [MAIN] Processing GS file: blob:http://127.0.0.1:5500/513a1be2-32e6-405e-aec0-47de526c5c35
|
| 41 |
+
main.js:507 [MAIN] Manual mode: true
|
| 42 |
+
main.js:519 [MAIN] fileName: fountain_trim9.gvrm
|
| 43 |
+
main.js:529 [MAIN] ===== STARTING MANUAL PREPROCESSING MODE =====
|
| 44 |
+
main.js:530 [MAIN] Parameters:
|
| 45 |
+
main.js:531 - vrmPath: ./assets/sotai.vrm
|
| 46 |
+
main.js:532 - gsPath: blob:http://127.0.0.1:5500/513a1be2-32e6-405e-aec0-47de526c5c35
|
| 47 |
+
main.js:533 - fileName: fountain_trim9.gvrm
|
| 48 |
+
preprocess_manual.js:977 [preprocessManual] ===== FUNCTION CALLED =====
|
| 49 |
+
preprocess_manual.js:978 [preprocessManual] Parameters:
|
| 50 |
+
preprocess_manual.js:979 vrmPath: ./assets/sotai.vrm
|
| 51 |
+
preprocess_manual.js:980 gsPath: blob:http://127.0.0.1:5500/513a1be2-32e6-405e-aec0-47de526c5c35
|
| 52 |
+
preprocess_manual.js:981 fileName: fountain_trim9.gvrm
|
| 53 |
+
preprocess_manual.js:984 [preprocessManual] Creating Promise...
|
| 54 |
+
preprocess_manual.js:84 [createManualUI] Creating manual preprocessing UI...
|
| 55 |
+
preprocess_manual.js:988 [preprocessManual] UI created
|
| 56 |
+
preprocess_manual.js:435 [ManualUI] initialize called
|
| 57 |
+
main.js:541 [MAIN] preprocessManual called, waiting for promise...
|
| 58 |
+
preprocess_manual.js:991 [preprocessManual] UI initialized, starting manual process...
|
| 59 |
+
preprocess_manual.js:1005 [preprocessManual] PLY loaded: 231474 vertices
|
| 60 |
+
preprocess_manual.js:1011 [preprocessManual] ===== ANALYZING PLY COORDINATE SYSTEM =====
|
| 61 |
+
preprocess_manual.js:1026 [PCA] Center: Object
|
| 62 |
+
preprocess_manual.js:1052 [PCA] Covariance matrix: Object
|
| 63 |
+
preprocess_manual.js:1067 [PCA] Variance ratios: Object
|
| 64 |
+
preprocess_manual.js:1080 [PCA] Is aligned with world axes: false
|
| 65 |
+
preprocess_manual.js:1120 [preprocessManual] ===== PLY DATA LOADED =====
|
| 66 |
+
preprocess_manual.js:1121 [preprocessManual] PLY data is in CAMERA coordinate space
|
| 67 |
+
preprocess_manual.js:1122 Total vertices: 231474
|
| 68 |
+
preprocess_manual.js:1141 [preprocessManual] PLY bounds (CAMERA space):
|
| 69 |
+
preprocess_manual.js:1142 Min: Object
|
| 70 |
+
preprocess_manual.js:1143 Max: Object
|
| 71 |
+
preprocess_manual.js:1144 Center: Object
|
| 72 |
+
preprocess_manual.js:1150 [preprocessManual] ✓ PLY coordinates preserved (CAMERA space)
|
| 73 |
+
preprocess_manual.js:1152 [preprocessManual] ===== COORDINATE SYSTEM CHECK =====
|
| 74 |
+
preprocess_manual.js:1155 World origin (0,0,0) in camera space: Object
|
| 75 |
+
preprocess_manual.js:1160 Camera position in world space: Object
|
| 76 |
+
preprocess_manual.js:1232 [preprocessManual] ✓ Coordinate transformation functions defined
|
| 77 |
+
preprocess_manual.js:1471 [preprocessManual] GS initialized
|
| 78 |
+
preprocess_manual.js:1490 [preprocessManual] No alignment transform needed for GS
|
| 79 |
+
preprocess_manual.js:1498 [preprocessManual] ✓ Camera controls created and saved globally
|
| 80 |
+
preprocess_manual.js:1507 [preprocessManual] Keyboard controls initialized
|
| 81 |
+
preprocess_manual.js:1557 [preprocessManual] ✓ Animation loop started with camera lock support
|
| 82 |
+
preprocess_manual.js:1610 [preprocessManual] Camera positioned at: Object
|
| 83 |
+
preprocess_manual.js:1617 [preprocessManual] Initial box setup - size: Object
|
| 84 |
+
preprocess_manual.js:1660 [preprocessManual] UI sliders initialized to PLY-aligned values
|
| 85 |
+
preprocess_manual.js:1666 [preprocessManual] ✓ Camera and Box aligned to PLY
|
| 86 |
+
preprocess_manual.js:1546 [animateControls] Status check: Object
|
| 87 |
+
preprocess_manual.js:1399
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
preprocess_manual.js:1400 ═══════════════════════════════════════════════════════
|
| 91 |
+
preprocess_manual.js:1401 CONFIRM BOX BUTTON CLICKED
|
| 92 |
+
preprocess_manual.js:1402 ═══════════════════════════════════════════════════════
|
| 93 |
+
preprocess_manual.js:1431 [CONFIRM] World box (from UI): Object
|
| 94 |
+
preprocess_manual.js:1434 [CONFIRM] Transforming box to camera space...
|
| 95 |
+
preprocess_manual.js:1438 [CONFIRM] Camera box (transformed): Object
|
| 96 |
+
preprocess_manual.js:1441 [CONFIRM] Displaying box in camera space...
|
| 97 |
+
preprocess_manual.js:1449 [CONFIRM] Filtering splats in camera space...
|
| 98 |
+
preprocess_manual.js:1296 [filterSplatsByCameraBox] ===== FILTERING START =====
|
| 99 |
+
preprocess_manual.js:1297 [filterSplatsByCameraBox] CAMERA-space box:
|
| 100 |
+
preprocess_manual.js:1298 Min: Object
|
| 101 |
+
preprocess_manual.js:1299 Max: Object
|
| 102 |
+
preprocess_manual.js:1300 Total vertices: 231474
|
| 103 |
+
preprocess_manual.js:1315 [filterSplatsByCameraBox] ===== FILTERING COMPLETE =====
|
| 104 |
+
preprocess_manual.js:1316 Filtered: 0 / 231474
|
| 105 |
+
preprocess_manual.js:1317 Retention rate: 0.0 %
|
| 106 |
+
preprocess_manual.js:1454 ═══════════════════════════════════════════════════════
|
| 107 |
+
preprocess_manual.js:1455 BOX FILTERING COMPLETE
|
| 108 |
+
preprocess_manual.js:1456 ═══════════════════════════════════════════════════════
|
| 109 |
+
preprocess_manual.js:1811
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
preprocess_manual.js:1812 ═══════════════════════════════════════════════════════
|
| 113 |
+
preprocess_manual.js:1813 CONFIRM BOX BUTTON CLICKED
|
| 114 |
+
preprocess_manual.js:1814 ═══════════════════════════════════════════════════════
|
| 115 |
+
preprocess_manual.js:1842 [STEP 1] Current BOX Settings (from UI):
|
| 116 |
+
preprocess_manual.js:1843 Box Size: Object
|
| 117 |
+
preprocess_manual.js:1844 Box Position: Object
|
| 118 |
+
preprocess_manual.js:1845 Box Rotation (radians): Object
|
| 119 |
+
preprocess_manual.js:1846 Box Rotation (degrees): Object
|
| 120 |
+
preprocess_manual.js:1851 PLY Offset: Object
|
| 121 |
+
preprocess_manual.js:1854 [STEP 1] Outer scope variables (for comparison):
|
| 122 |
+
preprocess_manual.js:1855 boxSize: Object
|
| 123 |
+
preprocess_manual.js:1856 boxPosition: Object
|
| 124 |
+
preprocess_manual.js:1857 boxRotation: Object
|
| 125 |
+
preprocess_manual.js:1858 plyOffset: Object
|
| 126 |
+
preprocess_manual.js:1862 [STEP 2] Centered PLY Data (should be ~0,0,0):
|
| 127 |
+
preprocess_manual.js:1863 Total vertices: 231474
|
| 128 |
+
preprocess_manual.js:1941 [STEP 3] No PLY offset to apply
|
| 129 |
+
preprocess_manual.js:1950 [STEP 4] ⭐ Transforming Box coordinates to GS local space
|
| 130 |
+
preprocess_manual.js:1967 [STEP 4] Box position transformation:
|
| 131 |
+
preprocess_manual.js:1968 World space: Object
|
| 132 |
+
preprocess_manual.js:1969 GS local space: Object
|
| 133 |
+
preprocess_manual.js:1994 [STEP 4] Box rotation transformation:
|
| 134 |
+
preprocess_manual.js:1995 World space (deg): Object
|
| 135 |
+
preprocess_manual.js:2000 GS local space (deg): Object
|
| 136 |
+
preprocess_manual.js:537 [filterSplatsByBox] ===== FILTERING START =====
|
| 137 |
+
preprocess_manual.js:538 [filterSplatsByBox] Input parameters:
|
| 138 |
+
preprocess_manual.js:539 Box Size: Object
|
| 139 |
+
preprocess_manual.js:540 Box Position: Object
|
| 140 |
+
preprocess_manual.js:541 Box Rotation (radians): Object
|
| 141 |
+
preprocess_manual.js:542 Box Rotation (degrees): Object
|
| 142 |
+
preprocess_manual.js:547 Total input vertices: 231474
|
| 143 |
+
preprocess_manual.js:557 [filterSplatsByBox] Box half-extents: Object
|
| 144 |
+
preprocess_manual.js:558 [filterSplatsByBox] Using epsilon: 0.01
|
| 145 |
+
preprocess_manual.js:565 [filterSplatsByBox] Rotation matrices created
|
| 146 |
+
preprocess_manual.js:610 [DEBUG] Pre-filter summary:
|
| 147 |
+
preprocess_manual.js:611 Inside: 202550
|
| 148 |
+
preprocess_manual.js:612 Outside: 28924
|
| 149 |
+
preprocess_manual.js:613 Boundary vertices (within 0.5m): 52505
|
| 150 |
+
preprocess_manual.js:616 [DEBUG] Sample boundary vertices:
|
| 151 |
+
preprocess_manual.js:618 V10: world(-1.17, 1.68, 2.06) → local(1.17, -1.68, 2.06) → IN (dist: 0.286m)
|
| 152 |
+
preprocess_manual.js:618 V14: world(-1.39, 2.23, 2.64) → local(1.39, -2.23, 2.64) → OUT (dist: 0.015m)
|
| 153 |
+
preprocess_manual.js:618 V15: world(-1.27, 1.95, 2.64) → local(1.27, -1.95, 2.64) → OUT (dist: 0.286m)
|
| 154 |
+
preprocess_manual.js:618 V22: world(-1.19, 2.12, 2.84) → local(1.19, -2.12, 2.84) → OUT (dist: 0.130m)
|
| 155 |
+
preprocess_manual.js:618 V23: world(-1.26, 2.01, 2.72) → local(1.26, -2.01, 2.72) → OUT (dist: 0.240m)
|
| 156 |
+
preprocess_manual.js:618 V34: world(-1.27, 1.99, 2.70) → local(1.27, -1.99, 2.70) → OUT (dist: 0.261m)
|
| 157 |
+
preprocess_manual.js:618 V35: world(-1.39, 2.06, 2.48) → local(1.39, -2.06, 2.48) → OUT (dist: 0.134m)
|
| 158 |
+
preprocess_manual.js:618 V36: world(-1.23, 1.77, 2.43) → local(1.23, -1.77, 2.43) → OUT (dist: 0.076m)
|
| 159 |
+
preprocess_manual.js:618 V37: world(-1.16, 1.77, 2.50) → local(1.16, -1.77, 2.50) → OUT (dist: 0.153m)
|
| 160 |
+
preprocess_manual.js:618 V38: world(-1.25, 1.75, 2.38) → local(1.25, -1.75, 2.38) → OUT (dist: 0.026m)
|
| 161 |
+
preprocess_manual.js:618 V39: world(-1.22, 1.76, 2.47) → local(1.22, -1.76, 2.47) → OUT (dist: 0.119m)
|
| 162 |
+
preprocess_manual.js:618 V40: world(-1.22, 2.41, 1.85) → local(1.22, -2.41, 1.85) → OUT (dist: 0.165m)
|
| 163 |
+
preprocess_manual.js:618 V41: world(-1.33, 1.70, 2.23) → local(1.33, -1.70, 2.23) → IN (dist: 0.120m)
|
| 164 |
+
preprocess_manual.js:618 V42: world(-1.40, 1.70, 2.13) → local(1.40, -1.70, 2.13) → IN (dist: 0.221m)
|
| 165 |
+
preprocess_manual.js:618 V43: world(-1.16, 1.68, 2.31) → local(1.16, -1.68, 2.31) → IN (dist: 0.038m)
|
| 166 |
+
preprocess_manual.js:618 V44: world(-1.23, 1.61, 2.24) → local(1.23, -1.61, 2.24) → IN (dist: 0.107m)
|
| 167 |
+
preprocess_manual.js:618 V45: world(-1.18, 1.61, 2.28) → local(1.18, -1.61, 2.28) → IN (dist: 0.067m)
|
| 168 |
+
preprocess_manual.js:618 V46: world(-1.24, 1.55, 2.22) → local(1.24, -1.55, 2.22) → IN (dist: 0.135m)
|
| 169 |
+
preprocess_manual.js:618 V47: world(-1.30, 1.62, 2.11) → local(1.30, -1.62, 2.11) → IN (dist: 0.239m)
|
| 170 |
+
preprocess_manual.js:618 V48: world(-1.09, 2.04, 1.16) → local(1.09, -2.04, 1.16) → IN (dist: 0.215m)
|
| 171 |
+
preprocess_manual.js:625 [filterSplatsByBox] Sample vertices (first 10):
|
| 172 |
+
preprocess_manual.js:646 Vertex 0: Object
|
| 173 |
+
preprocess_manual.js:646 Vertex 1: Object
|
| 174 |
+
preprocess_manual.js:646 Vertex 2: Object
|
| 175 |
+
preprocess_manual.js:646 Vertex 3: Object
|
| 176 |
+
preprocess_manual.js:646 Vertex 4: Object
|
| 177 |
+
preprocess_manual.js:646 Vertex 5: Object
|
| 178 |
+
preprocess_manual.js:646 Vertex 6: Object
|
| 179 |
+
preprocess_manual.js:646 Vertex 7: Object
|
| 180 |
+
preprocess_manual.js:646 Vertex 8: Object
|
| 181 |
+
preprocess_manual.js:646 Vertex 9: Object
|
| 182 |
+
preprocess_manual.js:681 [filterSplatsByBox] ===== FILTERING COMPLETE =====
|
| 183 |
+
preprocess_manual.js:682 [filterSplatsByBox] Results:
|
| 184 |
+
preprocess_manual.js:683 Filtered: 202550 / 231474
|
| 185 |
+
preprocess_manual.js:684 Retention rate: 87.5 %
|
| 186 |
+
preprocess_manual.js:700 [filterSplatsByBox] Filtered bounds (world space):
|
| 187 |
+
preprocess_manual.js:701 X: -1.400 to 2.071 (size: 3.470 )
|
| 188 |
+
preprocess_manual.js:702 Y: -0.542 to 2.260 (size: 2.802 )
|
| 189 |
+
preprocess_manual.js:703 Z: -0.838 to 2.360 (size: 3.198 )
|
| 190 |
+
preprocess_manual.js:704 Center: Object
|
| 191 |
+
preprocess_manual.js:710 [filterSplatsByBox] ℹ️ Box is rotated - World-space bounds will differ from box size
|
| 192 |
+
preprocess_manual.js:2038 [STEP 4] ✓ Filtering complete: 202550 splats kept
|
| 193 |
+
preprocess_manual.js:2048 [STEP 5] Centering splats...
|
| 194 |
+
preprocess_manual.js:2066 [STEP 5] Before centering: Object
|
| 195 |
+
preprocess_manual.js:2076 [STEP 5] ✓ Splats centered to origin
|
| 196 |
+
preprocess_manual.js:2079 [STEP 6] Saving filtered PLY...
|
| 197 |
+
preprocess_manual.js:770 [downloadPLY] Downloaded: 513a1be2-32e6-405e-aec0-47de526c5c35_filtered_2025-12-18T04-59-32.ply
|
| 198 |
+
preprocess_manual.js:2102 [STEP 6] ✓ PLY saved: 513a1be2-32e6-405e-aec0-47de526c5c35_filtered_2025-12-18T04-59-32.ply
|
| 199 |
+
preprocess_manual.js:2103 [STEP 6] Statistics:
|
| 200 |
+
preprocess_manual.js:2104 Original: 231474 vertices
|
| 201 |
+
preprocess_manual.js:2105 Filtered: 202550 vertices
|
| 202 |
+
preprocess_manual.js:2106 Reduction: 12.5 %
|
| 203 |
+
preprocess_manual.js:2117 [STEP 7] Loading filtered splats into viewer...
|
| 204 |
+
preprocess_manual.js:2130 [STEP 7] ✓ Filtered GS loaded
|
| 205 |
+
preprocess_manual.js:2136 [STEP 7] ✓ VRM loaded
|
| 206 |
+
preprocess_manual.js:2143 ═══════════════════════════════════════════════════════
|
| 207 |
+
preprocess_manual.js:2144 BOX FILTERING COMPLETE
|
| 208 |
+
preprocess_manual.js:2145 ═══════════════════════════════════════════════════════
|
| 209 |
+
preprocess_manual.js:2146
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
preprocess_manual.js:2201 [setupBoneAssignment] Starting bone assignment...
|
| 213 |
+
preprocess_manual.js:2233 [calculateOptimalRadius] Object size: Object
|
| 214 |
+
preprocess_manual.js:2234 [calculateOptimalRadius] Optimal radius: 0.17 m
|
| 215 |
+
preprocess_manual.js:2265 [setupBoneAssignment] Attempting to load default.json...
|
| 216 |
+
main.js:544 [MAIN] preprocessManual returned: Object
|
| 217 |
+
main.js:552 [MAIN] Manual preprocessing succeeded, setting up GVRM
|
| 218 |
+
preprocess_manual.js:2275 [setupBoneAssignment] ✓ default.json loaded successfully
|
| 219 |
+
preprocess_manual.js:2286 [setupBoneAssignment] Applying bone operations...
|
| 220 |
+
preprocess_manual.js:2302 [setupBoneAssignment] Available bones: 54
|
| 221 |
+
preprocess_manual.js:2303 [setupBoneAssignment] Bone names: Array(54)
|
| 222 |
+
preprocess_manual.js:2348 [updateBoneSelector] Updating for mode: required19
|
| 223 |
+
preprocess_manual.js:2360 [updateBoneSelector] Added 20 groups
|
| 224 |
+
preprocess_manual.js:2874 [setupBoneAssignment] ✓ Improved splat selection system initialized
|
| 225 |
+
preprocess_manual.js:2875 [setupBoneAssignment] Features:
|
| 226 |
+
preprocess_manual.js:2876 - Finds nearest splat within 50px (adjustable)
|
| 227 |
+
preprocess_manual.js:2877 - Paint mode with drag support
|
| 228 |
+
preprocess_manual.js:2878 - Smooth brush strokes with interpolation
|
| 229 |
+
preprocess_manual.js:2879 - Sphere selection with improved center detection
|
| 230 |
+
preprocess_manual.js:2888 [setupBoneAssignment] Camera controls initialized
|
| 231 |
+
preprocess_manual.js:2901 [setupBoneAssignment] Setting up camera lock...
|
| 232 |
+
preprocess_manual.js:2908 [setupBoneAssignment] ✓ Camera lock button found
|
| 233 |
+
preprocess_manual.js:2972 [setupBoneAssignment] ✓ Camera lock button configured
|
| 234 |
+
preprocess_manual.js:2973 [setupBoneAssignment] Initial state: UNLOCKED
|
| 235 |
+
preprocess_manual.js:2410 [setupBoneAssignment] Paint mode enabled
|
| 236 |
+
preprocess_manual.js:2395 [setupBoneAssignment] Selected target: group_0
|
| 237 |
+
preprocess_manual.js:2769 Uncaught ReferenceError: getTargetColor is not defined
|
| 238 |
+
at applyAssignmentToIndices (preprocess_manual.js:2769:25)
|
| 239 |
+
at handlePaintAtPosition (preprocess_manual.js:2736:5)
|
| 240 |
+
at HTMLCanvasElement.<anonymous> (preprocess_manual.js:2695:3)Understand this error
|
| 241 |
+
preprocess_manual.js:2995 [setupBoneAssignment] Assigning splats around center to group_0
|
| 242 |
+
preprocess_manual.js:3015 [setupBoneAssignment] Group: 1. Head Bones: Array(1)
|
| 243 |
+
preprocess_manual.js:2815 [Sphere Selection] Mode activated, radius: 0.1735071063041687 m
|
| 244 |
+
preprocess_manual.js:2816 [Sphere Selection] Click on a splat to select all nearby splats
|
| 245 |
+
preprocess_manual.js:3258 [setupBoneAssignment] Sphere selection mode activated
|
| 246 |
+
preprocess_manual.js:2769 Uncaught ReferenceError: getTargetColor is not defined
|
| 247 |
+
at applyAssignmentToIndices (preprocess_manual.js:2769:25)
|
| 248 |
+
at handlePaintAtPosition (preprocess_manual.js:2736:5)
|
| 249 |
+
at HTMLCanvasElement.<anonymous> (preprocess_manual.js:2695:3)Understand this error
|
| 250 |
+
preprocess_manual.js:2995 [setupBoneAssignment] Assigning splats around center to group_0
|
| 251 |
+
preprocess_manual.js:3015 [setupBoneAssignment] Group: 1. Head Bones: Array(1)
|
| 252 |
+
preprocess_manual.js:2495 [findNearestSplat] Searching for splat near mouse: Object
|
| 253 |
+
preprocess_manual.js:2550 [findNearestSplat] ✓ Found nearest splat: Object
|
| 254 |
+
preprocess_manual.js:2842 [Sphere Selection] Center splat: 23448 at Ci
|
| 255 |
+
preprocess_manual.js:2593 [findSplatsInSphere] Found 1854 splats within radius 0.17 m
|
| 256 |
+
preprocess_manual.js:2769 Uncaught ReferenceError: getTargetColor is not defined
|
| 257 |
+
at applyAssignmentToIndices (preprocess_manual.js:2769:25)
|
| 258 |
+
at HTMLCanvasElement.onSphereClick (preprocess_manual.js:2855:7)Understand this error
|
| 259 |
+
preprocess_manual.js:2769 Uncaught ReferenceError: getTargetColor is not defined
|
| 260 |
+
at applyAssignmentToIndices (preprocess_manual.js:2769:25)
|
| 261 |
+
at handlePaintAtPosition (preprocess_manual.js:2736:5)
|
| 262 |
+
at HTMLCanvasElement.<anonymous> (preprocess_manual.js:2695:3)Understand this error
|
| 263 |
+
preprocess_manual.js:2995 [setupBoneAssignment] Assigning splats around center to group_0
|
| 264 |
+
preprocess_manual.js:3015 [setupBoneAssignment] Group: 1. Head Bones: Array(1)
|
| 265 |
+
preprocess_manual.js:2495 [findNearestSplat] Searching for splat near mouse: Object
|
| 266 |
+
preprocess_manual.js:2550 [findNearestSplat] ✓ Found nearest splat: Object
|
| 267 |
+
preprocess_manual.js:2842 [Sphere Selection] Center splat: 150111 at Ci
|
| 268 |
+
preprocess_manual.js:2593 [findSplatsInSphere] Found 145978 splats within radius 2.00 m
|
| 269 |
+
preprocess_manual.js:2769 Uncaught ReferenceError: getTargetColor is not defined
|
| 270 |
+
at applyAssignmentToIndices (preprocess_manual.js:2769:25)
|
| 271 |
+
at HTMLCanvasElement.onSphereClick (preprocess_manual.js:2855:7)Understand this error
|
| 272 |
+
preprocess_manual.js:2769 Uncaught ReferenceError: getTargetColor is not defined
|
| 273 |
+
at applyAssignmentToIndices (preprocess_manual.js:2769:25)
|
| 274 |
+
at handlePaintAtPosition (preprocess_manual.js:2736:5)
|
| 275 |
+
at HTMLCanvasElement.<anonymous> (preprocess_manual.js:2695:3)Understand this error
|
| 276 |
+
preprocess_manual.js:2495 [findNearestSplat] Searching for splat near mouse: Object
|
| 277 |
+
preprocess_manual.js:2550 [findNearestSplat] ✓ Found nearest splat: Object
|
| 278 |
+
preprocess_manual.js:2842 [Sphere Selection] Center splat: 30800 at Ci
|
| 279 |
+
preprocess_manual.js:2593 [findSplatsInSphere] Found 130 splats within radius 1.10 m
|
| 280 |
+
preprocess_manual.js:2769 Uncaught ReferenceError: getTargetColor is not defined
|
| 281 |
+
at applyAssignmentToIndices (preprocess_manual.js:2769:25)
|
| 282 |
+
at HTMLCanvasElement.onSphereClick (preprocess_manual.js:2855:7)Understand this error
|
| 283 |
+
preprocess_manual.js:2738 [Paint] No splats found under cursor
|
| 284 |
+
preprocess_manual.js:2495 [findNearestSplat] Searching for splat near mouse: ObjectmouseX: -0.02228024368497783mouseY: -0.2568627450980392[[Prototype]]: Object
|
| 285 |
+
preprocess_manual.js:2550 [findNearestSplat] ✓ Found nearest splat: Objectindex: 31753screenDistance: "85.3px"worldDistance: "17.981m"[[Prototype]]: Object
|
| 286 |
+
preprocess_manual.js:2842 [Sphere Selection] Center splat: 31753 at Cix: 0.12565886974334717y: -0.028607049956917763z: 1.6636425256729126[[Prototype]]: Object
|
| 287 |
+
preprocess_manual.js:2593 [findSplatsInSphere] Found 4748 splats within radius 1.10 m
|
| 288 |
+
preprocess_manual.js:2769 Uncaught ReferenceError: getTargetColor is not defined
|
| 289 |
+
at applyAssignmentToIndices (preprocess_manual.js:2769:25)
|
| 290 |
+
at HTMLCanvasElement.onSphereClick (preprocess_manual.js:2855:7)Understand this error
|
preprocess_manual.js
CHANGED
|
@@ -2291,7 +2291,6 @@ function setupBoneAssignment(ui, scene, camera, renderer, gvrm, character, filte
|
|
| 2291 |
|
| 2292 |
character.currentVrm.scene.updateMatrixWorld(true);
|
| 2293 |
|
| 2294 |
-
|
| 2295 |
// Get VRM bone information
|
| 2296 |
const humanBones = character.currentVrm.humanoid.humanBones;
|
| 2297 |
const boneNames = Object.keys(humanBones);
|
|
@@ -2472,9 +2471,416 @@ function setupBoneAssignment(ui, scene, camera, renderer, gvrm, character, filte
|
|
| 2472 |
// ========================================
|
| 2473 |
// Raycaster Setup
|
| 2474 |
// ========================================
|
|
|
|
| 2475 |
const raycaster = new THREE.Raycaster();
|
| 2476 |
const mouse = new THREE.Vector2();
|
| 2477 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2478 |
// ========================================
|
| 2479 |
// ⭐ Camera Controls Setup
|
| 2480 |
// ========================================
|
|
@@ -2838,7 +3244,6 @@ function setupBoneAssignment(ui, scene, camera, renderer, gvrm, character, filte
|
|
| 2838 |
// ========================================
|
| 2839 |
// Sphere Selection Mode Button
|
| 2840 |
// ========================================
|
| 2841 |
-
const selectSphereBtn = document.getElementById('select-sphere-btn');
|
| 2842 |
|
| 2843 |
if (selectSphereBtn) {
|
| 2844 |
selectSphereBtn.addEventListener('click', () => {
|
|
|
|
| 2291 |
|
| 2292 |
character.currentVrm.scene.updateMatrixWorld(true);
|
| 2293 |
|
|
|
|
| 2294 |
// Get VRM bone information
|
| 2295 |
const humanBones = character.currentVrm.humanoid.humanBones;
|
| 2296 |
const boneNames = Object.keys(humanBones);
|
|
|
|
| 2471 |
// ========================================
|
| 2472 |
// Raycaster Setup
|
| 2473 |
// ========================================
|
| 2474 |
+
////ここから
|
| 2475 |
const raycaster = new THREE.Raycaster();
|
| 2476 |
const mouse = new THREE.Vector2();
|
| 2477 |
|
| 2478 |
+
//////挿入箇所start
|
| 2479 |
+
|
| 2480 |
+
// ========================================
|
| 2481 |
+
// 改善されたスプラット選択機能
|
| 2482 |
+
// setupBoneAssignment関数内のマウスクリック処理を置き換えてください
|
| 2483 |
+
// ========================================
|
| 2484 |
+
|
| 2485 |
+
/**
|
| 2486 |
+
* 2D画面座標から最も近い3D Splatを検索
|
| 2487 |
+
* @param {number} mouseX - 正規化されたマウスX座標 (-1 to 1)
|
| 2488 |
+
* @param {number} mouseY - 正規化されたマウスY座標 (-1 to 1)
|
| 2489 |
+
* @param {THREE.Camera} camera - カメラオブジェクト
|
| 2490 |
+
* @param {Object} filteredGs - Gaussian Splat データ
|
| 2491 |
+
* @param {number} maxScreenDistance - 最大許容画面距離(ピクセル、デフォルト50px)
|
| 2492 |
+
* @returns {Object|null} { index, screenDistance, worldDistance } or null
|
| 2493 |
+
*/
|
| 2494 |
+
function findNearestSplat(mouseX, mouseY, camera, filteredGs, maxScreenDistance = 50) {
|
| 2495 |
+
console.log('[findNearestSplat] Searching for splat near mouse:', { mouseX, mouseY });
|
| 2496 |
+
|
| 2497 |
+
// スクリーン座標をピクセル座標に変換
|
| 2498 |
+
const canvas = renderer.domElement;
|
| 2499 |
+
const mousePixelX = (mouseX + 1) * canvas.width / 2;
|
| 2500 |
+
const mousePixelY = (-mouseY + 1) * canvas.height / 2;
|
| 2501 |
+
|
| 2502 |
+
let nearestSplatIndex = -1;
|
| 2503 |
+
let nearestScreenDist = Infinity;
|
| 2504 |
+
let nearestWorldDist = Infinity;
|
| 2505 |
+
|
| 2506 |
+
// カメラ位置
|
| 2507 |
+
const cameraPos = camera.position;
|
| 2508 |
+
|
| 2509 |
+
// 一時的なVector3オブジェクト(パフォーマンス最適化)
|
| 2510 |
+
const worldPos = new THREE.Vector3();
|
| 2511 |
+
const screenPos = new THREE.Vector3();
|
| 2512 |
+
|
| 2513 |
+
// 全てのsplatをチェック
|
| 2514 |
+
for (let i = 0; i < filteredGs.splatCount; i++) {
|
| 2515 |
+
// Splatのワールド座標を取得
|
| 2516 |
+
worldPos.x = filteredGs.centers0[i * 3 + 0];
|
| 2517 |
+
worldPos.y = filteredGs.centers0[i * 3 + 1];
|
| 2518 |
+
worldPos.z = filteredGs.centers0[i * 3 + 2];
|
| 2519 |
+
|
| 2520 |
+
// ワールド座標 → スクリーン座標に変換
|
| 2521 |
+
screenPos.copy(worldPos);
|
| 2522 |
+
screenPos.project(camera);
|
| 2523 |
+
|
| 2524 |
+
// カメラの背後にあるsplatは除外
|
| 2525 |
+
if (screenPos.z > 1) continue;
|
| 2526 |
+
|
| 2527 |
+
// 正規化座標 → ピクセル座標
|
| 2528 |
+
const screenPixelX = (screenPos.x + 1) * canvas.width / 2;
|
| 2529 |
+
const screenPixelY = (-screenPos.y + 1) * canvas.height / 2;
|
| 2530 |
+
|
| 2531 |
+
// マウスとの2D距離(画面上)
|
| 2532 |
+
const dx = screenPixelX - mousePixelX;
|
| 2533 |
+
const dy = screenPixelY - mousePixelY;
|
| 2534 |
+
const screenDist = Math.sqrt(dx * dx + dy * dy);
|
| 2535 |
+
|
| 2536 |
+
// 最大許容距離以内で、最も近いものを記録
|
| 2537 |
+
if (screenDist < maxScreenDistance && screenDist < nearestScreenDist) {
|
| 2538 |
+
nearestScreenDist = screenDist;
|
| 2539 |
+
nearestSplatIndex = i;
|
| 2540 |
+
|
| 2541 |
+
// ワールド空間での距離も計算
|
| 2542 |
+
const worldDx = worldPos.x - cameraPos.x;
|
| 2543 |
+
const worldDy = worldPos.y - cameraPos.y;
|
| 2544 |
+
const worldDz = worldPos.z - cameraPos.z;
|
| 2545 |
+
nearestWorldDist = Math.sqrt(worldDx * worldDx + worldDy * worldDy + worldDz * worldDz);
|
| 2546 |
+
}
|
| 2547 |
+
}
|
| 2548 |
+
|
| 2549 |
+
if (nearestSplatIndex >= 0) {
|
| 2550 |
+
console.log('[findNearestSplat] ✓ Found nearest splat:', {
|
| 2551 |
+
index: nearestSplatIndex,
|
| 2552 |
+
screenDistance: nearestScreenDist.toFixed(1) + 'px',
|
| 2553 |
+
worldDistance: nearestWorldDist.toFixed(3) + 'm'
|
| 2554 |
+
});
|
| 2555 |
+
|
| 2556 |
+
return {
|
| 2557 |
+
index: nearestSplatIndex,
|
| 2558 |
+
screenDistance: nearestScreenDist,
|
| 2559 |
+
worldDistance: nearestWorldDist
|
| 2560 |
+
};
|
| 2561 |
+
}
|
| 2562 |
+
|
| 2563 |
+
console.log('[findNearestSplat] ✗ No splat found within', maxScreenDistance, 'px');
|
| 2564 |
+
return null;
|
| 2565 |
+
}
|
| 2566 |
+
|
| 2567 |
+
/**
|
| 2568 |
+
* 球体範囲内の全Splatを検索
|
| 2569 |
+
* @param {THREE.Vector3} center - 球の中心座標
|
| 2570 |
+
* @param {number} radius - 球の半径
|
| 2571 |
+
* @param {Object} filteredGs - Gaussian Splat データ
|
| 2572 |
+
* @returns {Array<number>} Splat インデックスの配列
|
| 2573 |
+
*/
|
| 2574 |
+
function findSplatsInSphere(center, radius, filteredGs) {
|
| 2575 |
+
const indicesInSphere = [];
|
| 2576 |
+
const radiusSquared = radius * radius;
|
| 2577 |
+
|
| 2578 |
+
for (let i = 0; i < filteredGs.splatCount; i++) {
|
| 2579 |
+
const x = filteredGs.centers0[i * 3 + 0];
|
| 2580 |
+
const y = filteredGs.centers0[i * 3 + 1];
|
| 2581 |
+
const z = filteredGs.centers0[i * 3 + 2];
|
| 2582 |
+
|
| 2583 |
+
const dx = x - center.x;
|
| 2584 |
+
const dy = y - center.y;
|
| 2585 |
+
const dz = z - center.z;
|
| 2586 |
+
const distSquared = dx * dx + dy * dy + dz * dz;
|
| 2587 |
+
|
| 2588 |
+
if (distSquared <= radiusSquared) {
|
| 2589 |
+
indicesInSphere.push(i);
|
| 2590 |
+
}
|
| 2591 |
+
}
|
| 2592 |
+
|
| 2593 |
+
console.log('[findSplatsInSphere] Found', indicesInSphere.length, 'splats within radius', radius.toFixed(2), 'm');
|
| 2594 |
+
return indicesInSphere;
|
| 2595 |
+
}
|
| 2596 |
+
|
| 2597 |
+
/**
|
| 2598 |
+
* ペイントモード用: マウスパスに沿ってSplatを塗る
|
| 2599 |
+
* @param {number} mouseX - 正規化マウスX
|
| 2600 |
+
* @param {number} mouseY - 正規化マウスY
|
| 2601 |
+
* @param {number} lastMouseX - 前のマウスX
|
| 2602 |
+
* @param {number} lastMouseY - 前のマウスY
|
| 2603 |
+
* @param {THREE.Camera} camera
|
| 2604 |
+
* @param {Object} filteredGs
|
| 2605 |
+
* @param {number} brushRadius - ブラシ半径(ピクセル、デフォルト30px)
|
| 2606 |
+
* @returns {Array<number>} 影響を受けたSplatインデックス
|
| 2607 |
+
*/
|
| 2608 |
+
function findSplatsAlongMousePath(mouseX, mouseY, lastMouseX, lastMouseY, camera, filteredGs, brushRadius = 30) {
|
| 2609 |
+
const affectedSplats = new Set();
|
| 2610 |
+
|
| 2611 |
+
// パスを補間(滑らかなストロークのため)
|
| 2612 |
+
const steps = 5;
|
| 2613 |
+
for (let step = 0; step <= steps; step++) {
|
| 2614 |
+
const t = step / steps;
|
| 2615 |
+
const interpX = lastMouseX + (mouseX - lastMouseX) * t;
|
| 2616 |
+
const interpY = lastMouseY + (mouseY - lastMouseY) * t;
|
| 2617 |
+
|
| 2618 |
+
// この位置の周辺Splatを検索
|
| 2619 |
+
const result = findNearestSplatWithRadius(interpX, interpY, camera, filteredGs, brushRadius);
|
| 2620 |
+
if (result && result.indices) {
|
| 2621 |
+
result.indices.forEach(idx => affectedSplats.add(idx));
|
| 2622 |
+
}
|
| 2623 |
+
}
|
| 2624 |
+
|
| 2625 |
+
return Array.from(affectedSplats);
|
| 2626 |
+
}
|
| 2627 |
+
|
| 2628 |
+
/**
|
| 2629 |
+
* ブラシ半径内の全Splatを返す
|
| 2630 |
+
* @param {number} mouseX - 正規化マウスX
|
| 2631 |
+
* @param {number} mouseY - 正規化マウスY
|
| 2632 |
+
* @param {THREE.Camera} camera
|
| 2633 |
+
* @param {Object} filteredGs
|
| 2634 |
+
* @param {number} brushRadius - ブラシ半径(ピクセル)
|
| 2635 |
+
* @returns {Object|null} { indices: Array<number> } or null
|
| 2636 |
+
*/
|
| 2637 |
+
function findNearestSplatWithRadius(mouseX, mouseY, camera, filteredGs, brushRadius) {
|
| 2638 |
+
const canvas = renderer.domElement;
|
| 2639 |
+
const mousePixelX = (mouseX + 1) * canvas.width / 2;
|
| 2640 |
+
const mousePixelY = (-mouseY + 1) * canvas.height / 2;
|
| 2641 |
+
|
| 2642 |
+
const affectedIndices = [];
|
| 2643 |
+
const worldPos = new THREE.Vector3();
|
| 2644 |
+
const screenPos = new THREE.Vector3();
|
| 2645 |
+
|
| 2646 |
+
for (let i = 0; i < filteredGs.splatCount; i++) {
|
| 2647 |
+
worldPos.x = filteredGs.centers0[i * 3 + 0];
|
| 2648 |
+
worldPos.y = filteredGs.centers0[i * 3 + 1];
|
| 2649 |
+
worldPos.z = filteredGs.centers0[i * 3 + 2];
|
| 2650 |
+
|
| 2651 |
+
screenPos.copy(worldPos);
|
| 2652 |
+
screenPos.project(camera);
|
| 2653 |
+
|
| 2654 |
+
if (screenPos.z > 1) continue;
|
| 2655 |
+
|
| 2656 |
+
const screenPixelX = (screenPos.x + 1) * canvas.width / 2;
|
| 2657 |
+
const screenPixelY = (-screenPos.y + 1) * canvas.height / 2;
|
| 2658 |
+
|
| 2659 |
+
const dx = screenPixelX - mousePixelX;
|
| 2660 |
+
const dy = screenPixelY - mousePixelY;
|
| 2661 |
+
const screenDist = Math.sqrt(dx * dx + dy * dy);
|
| 2662 |
+
|
| 2663 |
+
if (screenDist < brushRadius) {
|
| 2664 |
+
affectedIndices.push(i);
|
| 2665 |
+
}
|
| 2666 |
+
}
|
| 2667 |
+
|
| 2668 |
+
return affectedIndices.length > 0 ? { indices: affectedIndices } : null;
|
| 2669 |
+
}
|
| 2670 |
+
|
| 2671 |
+
// ========================================
|
| 2672 |
+
// マウスクリック/ドラッグイベント処理の改善例
|
| 2673 |
+
// ========================================
|
| 2674 |
+
|
| 2675 |
+
// グローバル変数
|
| 2676 |
+
let lastPaintMouseX = null;
|
| 2677 |
+
let lastPaintMouseY = null;
|
| 2678 |
+
|
| 2679 |
+
// マウスダウンイベント
|
| 2680 |
+
renderer.domElement.addEventListener('mousedown', (event) => {
|
| 2681 |
+
if (!isPaintMode || !selectedTarget) return;
|
| 2682 |
+
|
| 2683 |
+
isPainting = true;
|
| 2684 |
+
paintModeEraser = event.shiftKey;
|
| 2685 |
+
|
| 2686 |
+
// マウス座標を正規化
|
| 2687 |
+
const rect = renderer.domElement.getBoundingClientRect();
|
| 2688 |
+
mouse.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
|
| 2689 |
+
mouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
|
| 2690 |
+
|
| 2691 |
+
lastPaintMouseX = mouse.x;
|
| 2692 |
+
lastPaintMouseY = mouse.y;
|
| 2693 |
+
|
| 2694 |
+
// 最初のクリック位置でペイント
|
| 2695 |
+
handlePaintAtPosition(mouse.x, mouse.y);
|
| 2696 |
+
});
|
| 2697 |
+
|
| 2698 |
+
// マウスムーブイベント(ドラッグ中)
|
| 2699 |
+
renderer.domElement.addEventListener('mousemove', (event) => {
|
| 2700 |
+
if (!isPainting || !isPaintMode) return;
|
| 2701 |
+
|
| 2702 |
+
const rect = renderer.domElement.getBoundingClientRect();
|
| 2703 |
+
mouse.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
|
| 2704 |
+
mouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
|
| 2705 |
+
|
| 2706 |
+
// パスに沿ってペイント
|
| 2707 |
+
const affectedIndices = findSplatsAlongMousePath(
|
| 2708 |
+
mouse.x, mouse.y,
|
| 2709 |
+
lastPaintMouseX, lastPaintMouseY,
|
| 2710 |
+
camera, filteredGs,
|
| 2711 |
+
30 // ブラシ半径30px
|
| 2712 |
+
);
|
| 2713 |
+
|
| 2714 |
+
if (affectedIndices.length > 0) {
|
| 2715 |
+
applyAssignmentToIndices(affectedIndices, selectedTarget, paintModeEraser);
|
| 2716 |
+
}
|
| 2717 |
+
|
| 2718 |
+
lastPaintMouseX = mouse.x;
|
| 2719 |
+
lastPaintMouseY = mouse.y;
|
| 2720 |
+
});
|
| 2721 |
+
|
| 2722 |
+
// マウスアップイベント
|
| 2723 |
+
renderer.domElement.addEventListener('mouseup', () => {
|
| 2724 |
+
isPainting = false;
|
| 2725 |
+
lastPaintMouseX = null;
|
| 2726 |
+
lastPaintMouseY = null;
|
| 2727 |
+
});
|
| 2728 |
+
|
| 2729 |
+
/**
|
| 2730 |
+
* ペイント処理を実行
|
| 2731 |
+
*/
|
| 2732 |
+
function handlePaintAtPosition(mouseX, mouseY) {
|
| 2733 |
+
const result = findNearestSplatWithRadius(mouseX, mouseY, camera, filteredGs, 30);
|
| 2734 |
+
|
| 2735 |
+
if (result && result.indices.length > 0) {
|
| 2736 |
+
applyAssignmentToIndices(result.indices, selectedTarget, paintModeEraser);
|
| 2737 |
+
} else {
|
| 2738 |
+
console.log('[Paint] No splats found under cursor');
|
| 2739 |
+
}
|
| 2740 |
+
}
|
| 2741 |
+
|
| 2742 |
+
/**
|
| 2743 |
+
* Splatに割り当てを適用
|
| 2744 |
+
*/
|
| 2745 |
+
function applyAssignmentToIndices(indices, target, isEraser) {
|
| 2746 |
+
if (isEraser) {
|
| 2747 |
+
// 消しゴムモード: 割り当て解除
|
| 2748 |
+
indices.forEach(idx => {
|
| 2749 |
+
if (assignmentData.splatBoneIndices[idx] >= 0) {
|
| 2750 |
+
const oldBoneName = getBoneNameFromIndex(assignmentData.splatBoneIndices[idx]);
|
| 2751 |
+
if (assignmentData.boneAssignments[oldBoneName]) {
|
| 2752 |
+
const arrayIdx = assignmentData.boneAssignments[oldBoneName].indexOf(idx);
|
| 2753 |
+
if (arrayIdx >= 0) {
|
| 2754 |
+
assignmentData.boneAssignments[oldBoneName].splice(arrayIdx, 1);
|
| 2755 |
+
}
|
| 2756 |
+
}
|
| 2757 |
+
assignmentData.splatBoneIndices[idx] = -1;
|
| 2758 |
+
|
| 2759 |
+
// 色を元に戻す
|
| 2760 |
+
filteredGs.colors[idx * 4 + 0] = 255;
|
| 2761 |
+
filteredGs.colors[idx * 4 + 1] = 255;
|
| 2762 |
+
filteredGs.colors[idx * 4 + 2] = 255;
|
| 2763 |
+
}
|
| 2764 |
+
});
|
| 2765 |
+
|
| 2766 |
+
console.log('[Paint] Erased', indices.length, 'splats');
|
| 2767 |
+
} else {
|
| 2768 |
+
// 通常モード: 割り当て
|
| 2769 |
+
const targetColor = getTargetColor(target);
|
| 2770 |
+
const boneIndices = getTargetBoneIndices(target);
|
| 2771 |
+
|
| 2772 |
+
indices.forEach(idx => {
|
| 2773 |
+
assignmentData.splatBoneIndices[idx] = boneIndices[0]; // 最初のボーン
|
| 2774 |
+
|
| 2775 |
+
// 色を適用
|
| 2776 |
+
filteredGs.colors[idx * 4 + 0] = targetColor[0];
|
| 2777 |
+
filteredGs.colors[idx * 4 + 1] = targetColor[1];
|
| 2778 |
+
filteredGs.colors[idx * 4 + 2] = targetColor[2];
|
| 2779 |
+
|
| 2780 |
+
// 記録
|
| 2781 |
+
boneIndices.forEach(boneIdx => {
|
| 2782 |
+
const boneName = getBoneNameFromIndex(boneIdx);
|
| 2783 |
+
if (!assignmentData.boneAssignments[boneName]) {
|
| 2784 |
+
assignmentData.boneAssignments[boneName] = [];
|
| 2785 |
+
}
|
| 2786 |
+
if (!assignmentData.boneAssignments[boneName].includes(idx)) {
|
| 2787 |
+
assignmentData.boneAssignments[boneName].push(idx);
|
| 2788 |
+
}
|
| 2789 |
+
});
|
| 2790 |
+
});
|
| 2791 |
+
|
| 2792 |
+
console.log('[Paint] Painted', indices.length, 'splats with', target);
|
| 2793 |
+
}
|
| 2794 |
+
|
| 2795 |
+
// スプラットの色を更新
|
| 2796 |
+
filteredGs.splatMesh.updateDataTexturesFromBaseData(0, filteredGs.splatCount - 1);
|
| 2797 |
+
updateStats();
|
| 2798 |
+
}
|
| 2799 |
+
|
| 2800 |
+
// ========================================
|
| 2801 |
+
// 球体選択モード(元のコード互換)
|
| 2802 |
+
// ========================================
|
| 2803 |
+
|
| 2804 |
+
// Sphere Selection Button
|
| 2805 |
+
const selectSphereBtn = document.getElementById('select-sphere-btn');
|
| 2806 |
+
|
| 2807 |
+
if (selectSphereBtn) {
|
| 2808 |
+
selectSphereBtn.addEventListener('click', () => {
|
| 2809 |
+
if (!selectedTarget) {
|
| 2810 |
+
alert('Please select a target bone or group first!');
|
| 2811 |
+
return;
|
| 2812 |
+
}
|
| 2813 |
+
|
| 2814 |
+
selectionMode = 'sphere';
|
| 2815 |
+
console.log('[Sphere Selection] Mode activated, radius:', selectionRadius, 'm');
|
| 2816 |
+
console.log('[Sphere Selection] Click on a splat to select all nearby splats');
|
| 2817 |
+
|
| 2818 |
+
// One-time click listener
|
| 2819 |
+
const onSphereClick = (event) => {
|
| 2820 |
+
const rect = renderer.domElement.getBoundingClientRect();
|
| 2821 |
+
mouse.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
|
| 2822 |
+
mouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
|
| 2823 |
+
|
| 2824 |
+
// ⭐ 改善: 最も近いsplatを見つける
|
| 2825 |
+
const nearestResult = findNearestSplat(mouse.x, mouse.y, camera, filteredGs, 100);
|
| 2826 |
+
|
| 2827 |
+
if (!nearestResult) {
|
| 2828 |
+
alert('No splat found near click. Please click closer to the object.');
|
| 2829 |
+
renderer.domElement.removeEventListener('click', onSphereClick);
|
| 2830 |
+
selectionMode = null;
|
| 2831 |
+
return;
|
| 2832 |
+
}
|
| 2833 |
+
|
| 2834 |
+
const centerIdx = nearestResult.index;
|
| 2835 |
+
|
| 2836 |
+
// 中心点の座標
|
| 2837 |
+
const centerX = filteredGs.centers0[centerIdx * 3 + 0];
|
| 2838 |
+
const centerY = filteredGs.centers0[centerIdx * 3 + 1];
|
| 2839 |
+
const centerZ = filteredGs.centers0[centerIdx * 3 + 2];
|
| 2840 |
+
const center = new THREE.Vector3(centerX, centerY, centerZ);
|
| 2841 |
+
|
| 2842 |
+
console.log('[Sphere Selection] Center splat:', centerIdx, 'at', center);
|
| 2843 |
+
|
| 2844 |
+
// 球体範囲内のsplatを検索
|
| 2845 |
+
const indicesInSphere = findSplatsInSphere(center, selectionRadius, filteredGs);
|
| 2846 |
+
|
| 2847 |
+
if (indicesInSphere.length === 0) {
|
| 2848 |
+
alert('No splats found in sphere. Try increasing the radius.');
|
| 2849 |
+
renderer.domElement.removeEventListener('click', onSphereClick);
|
| 2850 |
+
selectionMode = null;
|
| 2851 |
+
return;
|
| 2852 |
+
}
|
| 2853 |
+
|
| 2854 |
+
// 割り当てを実行
|
| 2855 |
+
applyAssignmentToIndices(indicesInSphere, selectedTarget, false);
|
| 2856 |
+
|
| 2857 |
+
// 履歴に記録
|
| 2858 |
+
assignmentData.history.push({
|
| 2859 |
+
action: 'sphere_select',
|
| 2860 |
+
indices: [...indicesInSphere],
|
| 2861 |
+
target: selectedTarget
|
| 2862 |
+
});
|
| 2863 |
+
|
| 2864 |
+
console.log('[Sphere Selection] Completed:', indicesInSphere.length, 'splats assigned');
|
| 2865 |
+
|
| 2866 |
+
renderer.domElement.removeEventListener('click', onSphereClick);
|
| 2867 |
+
selectionMode = null;
|
| 2868 |
+
};
|
| 2869 |
+
|
| 2870 |
+
renderer.domElement.addEventListener('click', onSphereClick);
|
| 2871 |
+
});
|
| 2872 |
+
}
|
| 2873 |
+
|
| 2874 |
+
console.log('[setupBoneAssignment] ✓ Improved splat selection system initialized');
|
| 2875 |
+
console.log('[setupBoneAssignment] Features:');
|
| 2876 |
+
console.log(' - Finds nearest splat within 50px (adjustable)');
|
| 2877 |
+
console.log(' - Paint mode with drag support');
|
| 2878 |
+
console.log(' - Smooth brush strokes with interpolation');
|
| 2879 |
+
console.log(' - Sphere selection with improved center detection');
|
| 2880 |
+
|
| 2881 |
+
|
| 2882 |
+
///////挿入箇所end
|
| 2883 |
+
|
| 2884 |
// ========================================
|
| 2885 |
// ⭐ Camera Controls Setup
|
| 2886 |
// ========================================
|
|
|
|
| 3244 |
// ========================================
|
| 3245 |
// Sphere Selection Mode Button
|
| 3246 |
// ========================================
|
|
|
|
| 3247 |
|
| 3248 |
if (selectSphereBtn) {
|
| 3249 |
selectSphereBtn.addEventListener('click', () => {
|