stpete2 commited on
Commit
17cbfb6
·
verified ·
1 Parent(s): 7ef3f6a

Upload log.md

Browse files
Files changed (1) hide show
  1. log.md +251 -92
log.md CHANGED
@@ -1,92 +1,251 @@
1
- [preprocess_manual.js] ===== MODULE LOADING =====
2
- main.js:16 [MAIN] DOMContentLoaded fired
3
- main.js:269 [MAIN] Calling setupPathsFromUrlOrSelect...
4
- main.js:46 [MAIN] setupPathsFromUrlOrSelect started
5
- main.js:52 [MAIN] Initial paths - gsPath: undefined gvrmPath: undefined
6
- main.js:55 [MAIN] No paths in URL, showing select UI
7
- main.js:66 [MAIN] Elements check:
8
- main.js:67 - selectContainer: true
9
- main.js:68 - manualModeButton: true
10
- main.js:69 - manualFileInput: true
11
- main.js:117 [MAIN] Setting up file load promise
12
- main.js:172 [MAIN] Setting up manual mode listeners
13
- main.js:229 [MAIN] Manual mode listeners set up successfully
14
- main.js:259 [MAIN] Waiting for file load promise...
15
- main.js:175 [MAIN] ===== Manual mode button clicked! =====
16
- main.js:178 [MAIN] Opening manual file input...
17
- main.js:184 [MAIN] ===== Manual file input changed! =====
18
- main.js:186 [MAIN] File object: FilelastModified: 1765861881968lastModifiedDate: Tue Dec 16 2025 14:11:21 GMT+0900 (日本標準時) {}name: "fountain_trim7.ply"size: 65171963type: ""webkitRelativePath: ""[[Prototype]]: File
19
- main.js:190 [MAIN] Manual file selected: fountain_trim7.ply Extension: ply
20
- main.js:198 [MAIN] Reading manual file...
21
- main.js:201 [MAIN] Manual file read complete, size: 65171963
22
- main.js:209 [MAIN] Manual mode file loaded: fountain_trim7.ply
23
- main.js:210 [MAIN] gsPath: blob:http://127.0.0.1:5500/816dd4d7-9ac9-4a31-bc15-89c8c9f84546
24
- main.js:211 [MAIN] gsFileName: fountain_trim7.ply
25
- main.js:110 [MAIN] Hiding select UI
26
- main.js:215 [MAIN] ===== Resolving with MANUAL MODE =====
27
- main.js:261 [MAIN] File load promise resolved: ObjectgsPath: "blob:http://127.0.0.1:5500/816dd4d7-9ac9-4a31-bc15-89c8c9f84546"gvrmPath: undefinedmanualMode: true[[Prototype]]: Object
28
- main.js:271 [MAIN] setupPathsFromUrlOrSelect returned: Object
29
- main.js:277 [MAIN] After pathResult:
30
- main.js:278 - gsPath: blob:http://127.0.0.1:5500/816dd4d7-9ac9-4a31-bc15-89c8c9f84546
31
- main.js:279 - gvrmPath: undefined
32
- main.js:280 - isManualMode: true
33
- main.js:283 [MAIN] Initializing renderer...
34
- main.js:289 [MAIN] Initializing camera...
35
- main.js:316 [MAIN] Initializing scene...
36
- main.js:323 [MAIN] Three.js initialization complete
37
- main.js:506 [MAIN] Processing GS file: blob:http://127.0.0.1:5500/816dd4d7-9ac9-4a31-bc15-89c8c9f84546
38
- main.js:507 [MAIN] Manual mode: true
39
- main.js:519 [MAIN] fileName: fountain_trim7.gvrm
40
- main.js:529 [MAIN] ===== STARTING MANUAL PREPROCESSING MODE =====
41
- main.js:530 [MAIN] Parameters:
42
- main.js:531 - vrmPath: ./assets/sotai.vrm
43
- main.js:532 - gsPath: blob:http://127.0.0.1:5500/816dd4d7-9ac9-4a31-bc15-89c8c9f84546
44
- main.js:533 - fileName: fountain_trim7.gvrm
45
- preprocess_manual.js:977 [preprocessManual] ===== FUNCTION CALLED =====
46
- preprocess_manual.js:978 [preprocessManual] Parameters:
47
- preprocess_manual.js:979 vrmPath: ./assets/sotai.vrm
48
- preprocess_manual.js:980 gsPath: blob:http://127.0.0.1:5500/816dd4d7-9ac9-4a31-bc15-89c8c9f84546
49
- preprocess_manual.js:981 fileName: fountain_trim7.gvrm
50
- preprocess_manual.js:984 [preprocessManual] Creating Promise...
51
- preprocess_manual.js:84 [createManualUI] Creating manual preprocessing UI...
52
- preprocess_manual.js:988 [preprocessManual] UI created
53
- preprocess_manual.js:435 [ManualUI] initialize called
54
- main.js:541 [MAIN] preprocessManual called, waiting for promise...
55
- preprocess_manual.js:991 [preprocessManual] UI initialized, starting manual process...
56
- preprocess_manual.js:1005 [preprocessManual] PLY loaded: 262784 vertices
57
- preprocess_manual.js:1011 [preprocessManual] ===== ANALYZING PLY COORDINATE SYSTEM =====
58
- preprocess_manual.js:1026 [PCA] Center: Objectx: -0.2652678845128372y: 1.1990953609667259z: 0.923559379148402[[Prototype]]: Object
59
- preprocess_manual.js:1052 [PCA] Covariance matrix: Objectcxx: "0.38"cxy: "0.18"cxz: "0.09"cyy: "1.10"cyz: "1.00"czz: "1.24"[[Prototype]]: Object
60
- preprocess_manual.js:1067 [PCA] Variance ratios: Objectx: "14.0%"y: "40.4%"z: "45.6%"[[Prototype]]: Object
61
- preprocess_manual.js:1080 [PCA] Is aligned with world axes: false
62
- preprocess_manual.js:1113 [preprocessManual] ===== STARTING AUTO-ALIGNMENT =====
63
- preprocess_manual.js:1117 [DEBUG] Original vertices reference: Array(262784)
64
- preprocess_manual.js:1118 [DEBUG] Original first vertex: Objectx: "-0.738219"y: "0.244090"z: "0.748940"[[Prototype]]: Object
65
- preprocess_manual.js:1127 [preprocessManual] Step 1: Calculating center of mass...
66
- preprocess_manual.js:1142 [DEBUG] Center of mass: Objectx: "-0.265268"y: "1.199095"z: "0.923559"[[Prototype]]: Object
67
- preprocess_manual.js:1148 [DEBUG] First vertex BEFORE centering: Objectx: "-0.738219"y: "0.244090"z: "0.748940"[[Prototype]]: Object
68
- preprocess_manual.js:1157 [preprocessManual] Step 2: Centering PLY (in-place modification)...
69
- preprocess_manual.js:1166 [DEBUG] First vertex AFTER centering: Objectx: "-0.472951"y: "-0.955005"z: "-0.174620"[[Prototype]]: Object
70
- preprocess_manual.js:1173 [DEBUG] Vertices reference after centering: Array(262784)
71
- preprocess_manual.js:1174 [DEBUG] Is same reference? true
72
- preprocess_manual.js:1179 [preprocessManual] Step 3: Verifying centering...
73
- preprocess_manual.js:1192 [DEBUG] Average after centering: Objectx: "-0.000000000"y: "0.000000000"z: "0.000000000"[[Prototype]]: Object
74
- preprocess_manual.js:1208 [DEBUG] ✓ Centering SUCCESS! Average is effectively zero
75
- preprocess_manual.js:1209 [preprocessManual] PLY centered at origin
76
- preprocess_manual.js:1214 [preprocessManual] Step 4: Calculating bounding box...
77
- preprocess_manual.js:1217 [DEBUG] First 3 vertices before bbox calculation:
78
- preprocess_manual.js:1219 V0: Objectx: "-0.472951"y: "-0.955005"z: "-0.174620"[[Prototype]]: Object
79
- preprocess_manual.js:1219 V1: Objectx: "-0.443478"y: "-0.990319"z: "-0.194779"[[Prototype]]: Object
80
- preprocess_manual.js:1219 V2: Objectx: "-0.336042"y: "-0.721272"z: "-0.803300"[[Prototype]]: Object
81
- preprocess_manual.js:1245 [preprocessManual] Bounding box: Object
82
- error.js:58 [DEBUG] ❌ CRITICAL ERROR: Bounding box center is not at origin!
83
- console.error @ error.js:58Understand this error
84
- error.js:58 [DEBUG] This means vertices were modified between Step 3 and Step 4!
85
- console.error @ error.js:58Understand this error
86
- error.js:58 [DEBUG] Bbox center: Object
87
- console.error @ error.js:58Understand this error
88
- error.js:58 [DEBUG] Re-checking first vertex:
89
- console.error @ error.js:58Understand this error
90
- error.js:58 Current: Object
91
- console.error @ error.js:58Understand this error
92
- error.js:58 Original (from reference): Object
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ////1251行目から
2
+ // デバッグ: ここで中心がずれている場合は異常
3
+ if (Math.abs(bboxCenter.x) > 0.01 || Math.abs(bboxCenter.y) > 0.01 || Math.abs(bboxCenter.z) > 0.01) {
4
+ console.error('[DEBUG] CRITICAL ERROR: Bounding box center is not at origin!');
5
+ console.error('[DEBUG] This means vertices were modified between Step 3 and Step 4!');
6
+ console.error('[DEBUG] Bbox center:', bboxCenter);
7
+
8
+ // さらにデバッグ: 頂点を再チェック
9
+ console.error('[DEBUG] Re-checking first vertex:');
10
+ console.error(' Current:', {
11
+ x: plyData.vertices[0].x.toFixed(6),
12
+ y: plyData.vertices[0].y.toFixed(6),
13
+ z: plyData.vertices[0].z.toFixed(6)
14
+ });
15
+ console.error(' Original (from reference):', {
16
+ x: originalVerticesRef[0].x.toFixed(6),
17
+ y: originalVerticesRef[0].y.toFixed(6),
18
+ z: originalVerticesRef[0].z.toFixed(6)
19
+ });
20
+
21
+ alert('❌ CRITICAL ERROR in Step 4!\n\n' +
22
+ 'Bounding box center is not at origin:\n' +
23
+ 'Center: (' + bboxCenter.x.toFixed(3) + ', ' + bboxCenter.y.toFixed(3) + ', ' + bboxCenter.z.toFixed(3) + ')\n\n' +
24
+ 'This indicates a serious bug.\n' +
25
+ 'Please check the browser console for details.');
26
+ return;
27
+ }
28
+
29
+
30
+
31
+ ////3249行目から
32
+ try {
33
+ // ========================================
34
+ // 1. Calculate gsQuaternion and gsPosition
35
+ // ========================================
36
+
37
+
38
+ console.log('[setupBoneAssignment] Step 1: Calculate GS transform');
39
+
40
+ // Get the GS scene transform
41
+ const gsScene = filteredGs.viewer.splatMesh.scenes[0];
42
+ gsScene.updateMatrixWorld(true);
43
+
44
+ // Clone the world matrix
45
+ const gsWorldMatrix = gsScene.matrixWorld.clone();
46
+
47
+ // Extract position
48
+ const gsWorldPosition = new THREE.Vector3();
49
+ gsWorldPosition.setFromMatrixPosition(gsWorldMatrix);
50
+
51
+ console.log('[setupBoneAssignment] GS World Position:', {
52
+ x: gsWorldPosition.x,
53
+ y: gsWorldPosition.y,
54
+ z: gsWorldPosition.z
55
+ });
56
+
57
+ // Extract scale
58
+ const gsWorldScale = new THREE.Vector3();
59
+ gsWorldScale.setFromMatrixScale(gsWorldMatrix);
60
+
61
+ console.log('[setupBoneAssignment] GS World Scale:', {
62
+ x: gsWorldScale.x,
63
+ y: gsWorldScale.y,
64
+ z: gsWorldScale.z
65
+ });
66
+
67
+ // 重要: スケールを除去したmatrixからrotationを取得
68
+ const rotationMatrix = gsWorldMatrix.clone();
69
+ rotationMatrix.scale(new THREE.Vector3(
70
+ 1 / gsWorldScale.x,
71
+ 1 / gsWorldScale.y,
72
+ 1 / gsWorldScale.z
73
+ ));
74
+
75
+ // Extract rotation as quaternion
76
+ const gsWorldQuaternion = new THREE.Quaternion();
77
+ gsWorldQuaternion.setFromRotationMatrix(rotationMatrix);
78
+
79
+ console.log('[setupBoneAssignment] GS World Quaternion:', {
80
+ x: gsWorldQuaternion.x,
81
+ y: gsWorldQuaternion.y,
82
+ z: gsWorldQuaternion.z,
83
+ w: gsWorldQuaternion.w
84
+ });
85
+
86
+ // 修正: Identityチェックを追加
87
+ const isIdentity = (
88
+ Math.abs(gsWorldQuaternion.x) < 0.0001 &&
89
+ Math.abs(gsWorldQuaternion.y) < 0.0001 &&
90
+ Math.abs(gsWorldQuaternion.z) < 0.0001 &&
91
+ Math.abs(gsWorldQuaternion.w - 1.0) < 0.0001
92
+ );
93
+
94
+ if (isIdentity) {
95
+ console.log('[setupBoneAssignment] ✓ GS has identity rotation (no rotation applied)');
96
+ } else {
97
+ console.log('[setupBoneAssignment] ✓ GS has non-identity rotation');
98
+ }
99
+
100
+
101
+ ////////////////////////////////
102
+
103
+ // Assign to filteredGs
104
+ filteredGs.gsQuaternion = [
105
+ gsWorldQuaternion.x,
106
+ gsWorldQuaternion.y,
107
+ gsWorldQuaternion.z,
108
+ gsWorldQuaternion.w
109
+ ];
110
+
111
+ filteredGs.gsPosition = [
112
+ gsWorldPosition.x,
113
+ gsWorldPosition.y,
114
+ gsWorldPosition.z
115
+ ];
116
+
117
+
118
+ /////////////////////////////////////20251210
119
+
120
+ // ========================================
121
+ // 2. Calculate modelScale
122
+ // ========================================
123
+
124
+ // ========================================
125
+ // 修正4: modelScaleの計算を修正
126
+ // Line 1929付近
127
+ // ========================================
128
+
129
+ console.log('[setupBoneAssignment] Step 2: Calculate modelScale');
130
+
131
+ const humanBones = character.currentVrm.humanoid.humanBones;
132
+
133
+ if (!humanBones.hips || !humanBones.hips.node) {
134
+ throw new Error('hips bone not found');
135
+ }
136
+
137
+ if (!humanBones.leftUpperLeg || !humanBones.leftUpperLeg.node) {
138
+ throw new Error('leftUpperLeg bone not found');
139
+ }
140
+
141
+ const hipsNode = humanBones.hips.node;
142
+ const leftUpperLegNode = humanBones.leftUpperLeg.node;
143
+
144
+ // ⭐ 修正: matrixWorldを強制的に更新
145
+ character.currentVrm.scene.updateMatrixWorld(true);
146
+
147
+ // Get world positions
148
+ const hipsWorldPos = new THREE.Vector3();
149
+ hipsNode.getWorldPosition(hipsWorldPos);
150
+
151
+ const leftUpperLegWorldPos = new THREE.Vector3();
152
+ leftUpperLegNode.getWorldPosition(leftUpperLegWorldPos);
153
+
154
+ console.log('[setupBoneAssignment] Hips world position:', {
155
+ x: hipsWorldPos.x.toFixed(4),
156
+ y: hipsWorldPos.y.toFixed(4),
157
+ z: hipsWorldPos.z.toFixed(4)
158
+ });
159
+
160
+ console.log('[setupBoneAssignment] Left upper leg world position:', {
161
+ x: leftUpperLegWorldPos.x.toFixed(4),
162
+ y: leftUpperLegWorldPos.y.toFixed(4),
163
+ z: leftUpperLegWorldPos.z.toFixed(4)
164
+ });
165
+
166
+
167
+ /////////////////
168
+
169
+
170
+ const legLength = hipsWorldPos.distanceTo(leftUpperLegWorldPos);
171
+ console.log('[setupBoneAssignment] Raw leg length:', legLength);
172
+
173
+ // ⭐ 判定: legLengthが0.2以下の場合、VRMスケールが正しいと判断
174
+ if (legLength < 0.2) {
175
+ console.warn('[setupBoneAssignment] ⚠️ VRM has very small leg length:', legLength);
176
+ console.warn('[setupBoneAssignment] Using modelScale = 1.0 (no scaling needed)');
177
+ gvrm.modelScale = 1.0;
178
+ } else {
179
+ // 通常の計算
180
+ const standardLegLength = 0.45;
181
+ const calculatedModelScale = standardLegLength / legLength;
182
+
183
+ console.log('[setupBoneAssignment] Calculated modelScale:', calculatedModelScale);
184
+
185
+ // 適度なクランプ
186
+ const clampedModelScale = Math.max(0.1, Math.min(10.0, calculatedModelScale));
187
+
188
+ if (clampedModelScale !== calculatedModelScale) {
189
+ console.warn('[setupBoneAssignment] ⚠️ Clamped modelScale from', calculatedModelScale, 'to', clampedModelScale);
190
+ }
191
+
192
+ gvrm.modelScale = clampedModelScale;
193
+ }
194
+
195
+ console.log('[setupBoneAssignment] ✓ Final gvrm.modelScale:', gvrm.modelScale);
196
+
197
+ ///////////////////////
198
+
199
+
200
+ // ========================================
201
+ // 3. Update boneOperations (optional but recommended)
202
+ // ========================================
203
+
204
+ console.log('[setupBoneAssignment] Step 3: Update boneOperations');
205
+
206
+ // The current boneOperations already has the correct structure
207
+ // We could update rotations based on the actual pose, but it's optional
208
+
209
+ // For now, just log the current boneOperations
210
+ console.log('[setupBoneAssignment] Current boneOperations:', gvrm.boneOperations);
211
+
212
+ // ========================================
213
+ // Verification
214
+ // ========================================
215
+
216
+ console.log('[setupBoneAssignment] ===== TRANSFORM CALCULATION COMPLETE =====');
217
+ console.log('[setupBoneAssignment] Final values:');
218
+ console.log(' modelScale:', gvrm.modelScale);
219
+ console.log(' gsQuaternion:', filteredGs.gsQuaternion);
220
+ console.log(' gsPosition:', filteredGs.gsPosition);
221
+ console.log(' boneOperations:', gvrm.boneOperations.length, 'operations');
222
+
223
+ // Sanity checks
224
+ if (gvrm.modelScale < 0.5 || gvrm.modelScale > 2.0) {
225
+ console.warn('[setupBoneAssignment] ⚠️ WARNING: modelScale is outside normal range (0.5-2.0)');
226
+ console.warn('[setupBoneAssignment] This may cause rendering issues');
227
+ }
228
+
229
+ if (filteredGs.gsQuaternion[0] === 0 &&
230
+ filteredGs.gsQuaternion[1] === 0 &&
231
+ filteredGs.gsQuaternion[2] === 1 &&
232
+ filteredGs.gsQuaternion[3] === 0) {
233
+ console.warn('[setupBoneAssignment] ⚠️ WARNING: gsQuaternion is still default value!');
234
+ }
235
+
236
+ if (filteredGs.gsPosition[0] === 0 &&
237
+ filteredGs.gsPosition[1] === 0 &&
238
+ filteredGs.gsPosition[2] === 0) {
239
+ console.warn('[setupBoneAssignment] ⚠️ WARNING: gsPosition is still (0,0,0)!');
240
+ console.warn('[setupBoneAssignment] This means the GS has no offset from origin');
241
+ }
242
+
243
+ ui.setStatus('Transform calculation complete');
244
+
245
+ } catch (error) {
246
+ console.error('[setupBoneAssignment] ERROR in transform calculation:', error);
247
+ console.error('[setupBoneAssignment] Error stack:', error.stack);
248
+ alert('Error calculating transforms: ' + error.message);
249
+ throw error;
250
+ }
251
+