stpete2 commited on
Commit
1f70499
·
verified ·
1 Parent(s): dafb889

Upload preprocess_manual.js

Browse files
Files changed (1) hide show
  1. preprocess_manual.js +268 -272
preprocess_manual.js CHANGED
@@ -75,6 +75,11 @@ function setupCameraControls(camera, renderer) {
75
 
76
  //////////////////////////////////////////12/13 17:30
77
 
 
 
 
 
 
78
  function createManualUI(scene, camera, renderer) {
79
  console.log('[createManualUI] Creating manual preprocessing UI...');
80
 
@@ -139,6 +144,26 @@ function createManualUI(scene, camera, renderer) {
139
  <!-- Bounding Box Controls -->
140
  <h4 style="margin: 15px 0 10px 0; color: #4CAF50;">📦 Bounding Box</h4>
141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  <div style="margin: 10px 0;">
143
  <label>Box X Size: <span id="box-x-value-step0">3.0</span>m</label><br>
144
  <input type="range" id="box-x-step0" min="0.5" max="50.0" step="0.1" value="3.0" style="width: 100%;">
@@ -165,6 +190,8 @@ function createManualUI(scene, camera, renderer) {
165
  <input type="range" id="box-z-pos-step0" min="-25.0" max="25.0" step="0.1" value="0.0" style="width: 100%;">
166
  </div>
167
 
 
 
168
  <!-- PLY Offset Controls (Optional Fine-Tuning) -->
169
  <h4 style="margin: 15px 0 10px 0; color: #2196F3;">🎯 Fine-tune PLY Position (Optional)</h4>
170
 
@@ -180,24 +207,7 @@ function createManualUI(scene, camera, renderer) {
180
  <label>PLY Z Offset: <span id="ply-z-value">0.0</span>m</label><br>
181
  <input type="range" id="ply-z" min="-10.0" max="10.0" step="0.1" value="0.0" style="width: 100%;">
182
  </div>
183
- <!-- Box Rotation Controls -->
184
- <h4 style="margin: 15px 0 10px 0; color: #FF9800;">🔄 Box Rotation</h4>
185
 
186
- <div style="margin: 10px 0;">
187
- <label>Rotate Y (Yaw): <span id="box-rot-y-value-step0">0</span>°</label><br>
188
- <input type="range" id="box-rot-y-step0" min="-180" max="180" step="1" value="0" style="width: 100%;">
189
- </div>
190
- <div style="margin: 10px 0;">
191
- <label>Rotate X (Pitch): <span id="box-rot-x-value-step0">0</span>°</label><br>
192
- <input type="range" id="box-rot-x-step0" min="-90" max="90" step="1" value="0" style="width: 100%;">
193
- </div>
194
- <div style="margin: 10px 0;">
195
- <label>Rotate Z (Roll): <span id="box-rot-z-value-step0">0</span>°</label><br>
196
- <input type="range" id="box-rot-z-step0" min="-180" max="180" step="1" value="0" style="width: 100%;">
197
- </div>
198
-
199
-
200
-
201
  <button id="reset-all-btn" style="
202
  margin-top: 10px;
203
  padding: 8px 15px;
@@ -221,244 +231,181 @@ function createManualUI(scene, camera, renderer) {
221
  ">✓ Confirm & Filter</button>
222
  </div>
223
 
224
- <!-- Step 1: Box Adjustment -->
225
- <div id="manual-controls" style="margin-top: 20px; display: none;">
226
- <h3>Step 1: Adjust Bounding Box</h3>
227
- <p style="font-size: 12px; color: #aaa;">
228
- Adjust the box to include only the person
229
- </p>
230
-
231
- <div style="margin: 10px 0;">
232
- <label>X Size: <span id="box-x-value">Auto</span>m</label><br>
233
- <input type="range" id="box-x" min="0.5" max="20.0" step="0.1" value="2.0" style="width: 100%;">
234
- </div>
235
- <div style="margin: 10px 0;">
236
- <label>Y Size: <span id="box-y-value">Auto</span>m</label><br>
237
- <input type="range" id="box-y" min="0.5" max="20.0" step="0.1" value="2.0" style="width: 100%;">
238
- </div>
239
- <div style="margin: 10px 0;">
240
- <label>Z Size: <span id="box-z-value">Auto</span>m</label><br>
241
- <input type="range" id="box-z" min="0.5" max="20.0" step="0.1" value="2.0" style="width: 100%;">
242
- </div>
243
- <div style="margin: 10px 0;">
244
- <label>Y Position: <span id="box-y-pos-value">Auto</span>m</label><br>
245
- <input type="range" id="box-y-pos" min="-20.0" max="20.0" step="0.1" value="0.0" style="width: 100%;">
246
- </div>
247
-
248
-
249
- <div style="margin: 10px 0;">
250
- // ==========================================
251
- // 使用方法
252
- // ==========================================
253
-
254
- /**
255
- * 1. ファイル冒頭のCUSTOM_BOX_SCALEを編集
256
- * 2. enabled: trueに設定
257
- * 3. scale配列で[X, Y, Z]のサイズを指定(メートル単位)
258
- * 4. position配列で[X, Y, Z]の位置を指定
259
- * 5. ファイルを保存して実行
260
- *
261
- * 例: ガンダム(18m)の場合
262
- *
263
- * const CUSTOM_BOX_SCALE = {
264
- * enabled: true,
265
- * scale: [20.0, 30.0, 20.0], // 幅20m、高さ30m、奥行20m
266
- * position: [0, 15, 0] // 地面から15m上に配置
267
- * };
268
- */
269
- </div>
270
-
271
- <button id="apply-box-btn" style="
272
- margin-top: 20px;
273
- padding: 10px 20px;
274
- background: #4CAF50;
275
- color: white;
276
- border: none;
277
- border-radius: 5px;
278
- cursor: pointer;
279
- font-size: 16px;
280
- width: 100%;
281
- ">Apply Box Filter</button>
282
-
283
-
284
-
285
 
286
- <!-- Step 2: Bone Assignment -->
287
- <div id="bone-assignment-section" style="display: none; margin-top: 30px;">
288
- <h3>Step 2: Assign Splats to Bones</h3>
289
-
290
- <!-- Paint Mode Toggle -->
291
- <div style="
292
- margin: 15px 0;
293
- padding: 10px;
294
- background: #1a1a2e;
295
- border-radius: 5px;
296
- border-left: 3px solid #2196F3;
 
 
 
 
 
 
297
  ">
298
- <label style="display: flex; align-items: center; cursor: pointer;">
299
- <input type="checkbox" id="paint-mode-toggle" style="margin-right: 10px;">
300
- <span>🎨 <strong>Paint Mode</strong> - Click and drag to paint over selections</span>
301
- </label>
302
- <div id="paint-mode-hint" style="
303
- font-size: 11px;
304
- color: #aaa;
305
- margin-top: 5px;
306
- display: none;
307
- ">
308
- Hold Shift to erase (unassign splats)
309
- </div>
310
- </div>
311
-
312
- <!-- Preset Selection -->
313
- <div style="margin: 15px 0;">
314
- <label style="display: block; margin-bottom: 5px; font-weight: bold;">Assignment Mode:</label>
315
- <select id="preset-selector" style="
316
- width: 100%;
317
- padding: 8px;
318
- font-size: 14px;
319
- border-radius: 5px;
320
- background: #333;
321
- color: white;
322
- border: 1px solid #555;
323
- margin-bottom: 10px;
324
- ">
325
- <option value="required19">✓ Required (19 parts) - All Essential Bones</option>
326
- </select>
327
- <div id="preset-description" style="
328
- font-size: 11px;
329
- color: #aaa;
330
- padding: 8px;
331
- background: #222;
332
- border-radius: 5px;
333
- margin-bottom: 10px;
334
- "></div>
335
- </div>
336
-
337
- <!-- Bone/Group Selector -->
338
- <div id="bone-selector-container" style="margin: 15px 0;">
339
- <label style="display: block; margin-bottom: 5px;">Select Target:</label>
340
- <select id="bone-selector" style="
341
- width: 100%;
342
- padding: 8px;
343
- font-size: 14px;
344
- border-radius: 5px;
345
- background: #333;
346
- color: white;
347
- border: 1px solid #555;
348
- ">
349
- <option value="">-- Select target --</option>
350
- </select>
351
  </div>
352
-
353
- <!-- Selection Tools -->
354
- <div style="margin: 15px 0;">
355
- <h4 style="margin-bottom: 10px;">Selection Method:</h4>
356
-
357
- <div style="margin: 10px 0;">
358
- <button id="select-sphere-btn" style="
359
- padding: 8px 15px;
360
- background: #FF9800;
361
- color: white;
362
- border: none;
363
- border-radius: 5px;
364
- cursor: pointer;
365
- width: 100%;
366
- ">🎯 Select by Sphere (Click on GS)</button>
367
- </div>
368
-
369
- <div style="margin: 10px 0;">
370
- <label>Selection Radius: <span id="selection-radius-value">0.2</span>m</label><br>
371
- <input type="range" id="selection-radius" min="0.05" max="1.0" step="0.05" value="0.2" style="width: 100%;">
372
- </div>
373
- </div>
374
-
375
- <!-- Camera Lock Button -->
376
- <div style="margin: 15px 0; padding: 10px; background: #1a1a2e; border-radius: 5px;">
377
- <button id="camera-lock-btn" style="
378
- padding: 10px 15px;
379
- background: #9C27B0;
380
- color: white;
381
- border: none;
382
- border-radius: 5px;
383
- cursor: pointer;
384
- width: 100%;
385
- font-weight: bold;
386
- ">🔓 Camera Unlocked (Can Rotate)</button>
387
- <div style="font-size: 11px; color: #aaa; margin-top: 5px;">
388
- Lock camera to prevent accidental movement while painting
389
- </div>
390
- </div>
391
-
392
 
393
- <!-- Statistics -->
394
- <div id="assignment-info" style="
395
- margin: 15px 0;
396
- padding: 10px;
397
- background: #222;
 
 
398
  border-radius: 5px;
399
- font-size: 12px;
 
 
 
400
  ">
401
- <div>Total Splats: <span id="total-splats">0</span></div>
402
- <div>Assigned: <span id="assigned-splats">0</span></div>
403
- <div>Unassigned: <span id="unassigned-splats">0</span></div>
404
- <div style="margin-top: 5px; padding-top: 5px; border-top: 1px solid #444;">
405
- Progress: <span id="assignment-progress">0%</span>
406
- </div>
407
- </div>
408
-
409
- <!-- Assignment List -->
410
- <div id="bone-assignment-list" style="
411
- max-height: 150px;
412
- overflow-y: auto;
413
- margin: 15px 0;
414
- padding: 10px;
415
  background: #222;
416
  border-radius: 5px;
417
- font-size: 11px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
418
  ">
419
- <div style="color: #888;">No assignments yet</div>
420
- </div>
 
 
 
 
 
421
 
422
- <!-- Control Buttons -->
423
- <div style="margin: 15px 0;">
424
- <button id="clear-selection-btn" style="
425
  padding: 8px 15px;
426
- background: #f44336;
427
  color: white;
428
  border: none;
429
  border-radius: 5px;
430
  cursor: pointer;
431
- width: 48%;
432
- margin-right: 2%;
433
- ">↶ Undo Last</button>
434
-
435
- <button id="undo-all-btn" style="
436
- padding: 8px 15px;
437
- background: #FF5722;
438
- color: white;
439
- border: none;
440
- border-radius: 5px;
441
- cursor: pointer;
442
- width: 48%;
443
- ">⟲ Reset All</button>
444
  </div>
445
 
446
- <button id="finalize-btn" style="
447
- margin-top: 20px;
448
- padding: 10px 20px;
449
- background: #2196F3;
 
 
 
 
 
 
 
 
 
450
  color: white;
451
  border: none;
452
  border-radius: 5px;
453
  cursor: pointer;
454
- font-size: 16px;
455
  width: 100%;
456
- ">✓ Finalize and Save</button>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
457
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
458
  </div>
459
  `;
460
 
461
-
462
  document.body.appendChild(uiContainer);
463
 
464
  let boundingBoxHelper = null;
@@ -499,42 +446,30 @@ function createManualUI(scene, camera, renderer) {
499
  if (controlsEl) controlsEl.style.display = 'block';
500
  },
501
 
502
- //////////////12/13 17:15 start
503
-
504
  createBoundingBox: function(size = { x: 2, y: 2, z: 2 }, position = { x: 0, y: 0, z: 0 }, rotation = { x: 0, y: 0, z: 0 }) {
505
- if (boundingBoxHelper) {
506
- scene.remove(boundingBoxHelper);
507
- }
508
-
509
- const geometry = new THREE.BoxGeometry(size.x, size.y, size.z);
510
- const edges = new THREE.EdgesGeometry(geometry);
511
- const material = new THREE.LineBasicMaterial({ color: 0x00ff00, linewidth: 2 });
512
- boundingBoxHelper = new THREE.LineSegments(edges, material);
513
- boundingBoxHelper.position.set(position.x, position.y, position.z);
514
-
515
- // ⭐ 回転を追加 (Euler angles in radians)
516
- boundingBoxHelper.rotation.set(rotation.x, rotation.y, rotation.z);
517
-
518
- scene.add(boundingBoxHelper);
519
-
520
- return boundingBoxHelper;
521
- },
522
-
523
- updateBoundingBox: function(size, position, rotation = { x: 0, y: 0, z: 0 }) {
524
- if (boundingBoxHelper) {
525
- scene.remove(boundingBoxHelper);
526
- }
527
- return this.createBoundingBox(size, position, rotation);
528
- },
529
-
530
- //////////////12/13 17:15 end
531
-
532
-
533
- updateBoundingBox: function(size, position) {
534
  if (boundingBoxHelper) {
535
  scene.remove(boundingBoxHelper);
536
  }
537
- return this.createBoundingBox(size, position);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
538
  },
539
 
540
  removeBoundingBox: function() {
@@ -559,7 +494,6 @@ updateBoundingBox: function(size, position, rotation = { x: 0, y: 0, z: 0 }) {
559
  }
560
  };
561
  }
562
-
563
  /**
564
  * Bounding Box内のスプラットのみをフィルタリング
565
  */
@@ -1258,6 +1192,62 @@ function setupBoneAssignment(ui, scene, camera, renderer, gvrm, character, filte
1258
  console.log('[setupBoneAssignment] Starting bone assignment...');
1259
 
1260
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1261
  // Load default bone operations
1262
  let response = await fetch("./assets/default.json");
1263
  const params = await response.json();
@@ -1288,7 +1278,7 @@ function setupBoneAssignment(ui, scene, camera, renderer, gvrm, character, filte
1288
  let selectedTarget = null;
1289
  let currentBoneGroups = PRESET_BONE_GROUPS.required19;
1290
  let selectionMode = null;
1291
- let selectionRadius = 0.2;
1292
 
1293
  // ========================================
1294
  // Paint Mode Variables
@@ -1308,6 +1298,12 @@ function setupBoneAssignment(ui, scene, camera, renderer, gvrm, character, filte
1308
  'required19': 'Required mode: Assign to 20 individual body parts (20-30 min). All bones assigned individually.'
1309
  };
1310
 
 
 
 
 
 
 
1311
  function updateBoneSelector(mode) {
1312
  if (!boneSelector) {
1313
  console.error('[updateBoneSelector] boneSelector not found');
@@ -1427,8 +1423,8 @@ function setupBoneAssignment(ui, scene, camera, renderer, gvrm, character, filte
1427
  // ========================================
1428
  // Selection Radius
1429
  // ========================================
1430
- const selectionRadiusSlider = document.getElementById('selection-radius');
1431
- const selectionRadiusValue = document.getElementById('selection-radius-value');
1432
 
1433
  if (selectionRadiusSlider && selectionRadiusValue) {
1434
  selectionRadiusSlider.addEventListener('input', (e) => {
@@ -1652,13 +1648,13 @@ function setupBoneAssignment(ui, scene, camera, renderer, gvrm, character, filte
1652
  if (intersects.length > 0) {
1653
  const hitPoint = intersects[0].point;
1654
 
1655
- if (paintModeEraser) {
1656
- // Erase mode: unassign splats (smaller radius for precision)
1657
- eraseSplatsInSphere(hitPoint, selectionRadius * 0.5);
1658
- } else {
1659
- // Paint mode: assign splats (smaller radius for precision)
1660
- assignSplatsInSphere(hitPoint, selectionRadius * 0.5, selectedTarget, true);
1661
- }
1662
  }
1663
  }
1664
 
 
75
 
76
  //////////////////////////////////////////12/13 17:30
77
 
78
+ // ========================================
79
+ // 完全に修正された createManualUI 関数
80
+ // Line 75 から Line 537 までを、この全体で置き換えてください
81
+ // ========================================
82
+
83
  function createManualUI(scene, camera, renderer) {
84
  console.log('[createManualUI] Creating manual preprocessing UI...');
85
 
 
144
  <!-- Bounding Box Controls -->
145
  <h4 style="margin: 15px 0 10px 0; color: #4CAF50;">📦 Bounding Box</h4>
146
 
147
+ <!-- Box Rotation Controls -->
148
+ <h4 style="margin: 15px 0 10px 0; color: #FF9800;">🔄 Box Rotation</h4>
149
+
150
+ <div style="margin: 10px 0;">
151
+ <label>Rotate Y (Yaw): <span id="box-rot-y-value-step0">0</span>°</label><br>
152
+ <input type="range" id="box-rot-y-step0" min="-180" max="180" step="1" value="0" style="width: 100%;">
153
+ </div>
154
+ <div style="margin: 10px 0;">
155
+ <label>Rotate X (Pitch): <span id="box-rot-x-value-step0">0</span>°</label><br>
156
+ <input type="range" id="box-rot-x-step0" min="-90" max="90" step="1" value="0" style="width: 100%;">
157
+ </div>
158
+ <div style="margin: 10px 0;">
159
+ <label>Rotate Z (Roll): <span id="box-rot-z-value-step0">0</span>°</label><br>
160
+ <input type="range" id="box-rot-z-step0" min="-180" max="180" step="1" value="0" style="width: 100%;">
161
+ </div>
162
+
163
+
164
+
165
+
166
+
167
  <div style="margin: 10px 0;">
168
  <label>Box X Size: <span id="box-x-value-step0">3.0</span>m</label><br>
169
  <input type="range" id="box-x-step0" min="0.5" max="50.0" step="0.1" value="3.0" style="width: 100%;">
 
190
  <input type="range" id="box-z-pos-step0" min="-25.0" max="25.0" step="0.1" value="0.0" style="width: 100%;">
191
  </div>
192
 
193
+
194
+
195
  <!-- PLY Offset Controls (Optional Fine-Tuning) -->
196
  <h4 style="margin: 15px 0 10px 0; color: #2196F3;">🎯 Fine-tune PLY Position (Optional)</h4>
197
 
 
207
  <label>PLY Z Offset: <span id="ply-z-value">0.0</span>m</label><br>
208
  <input type="range" id="ply-z" min="-10.0" max="10.0" step="0.1" value="0.0" style="width: 100%;">
209
  </div>
 
 
210
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  <button id="reset-all-btn" style="
212
  margin-top: 10px;
213
  padding: 8px 15px;
 
231
  ">✓ Confirm & Filter</button>
232
  </div>
233
 
234
+ <!-- Step 2のセクションをここに移動(manual-controlsの外へ) -->
235
+ <div id="bone-assignment-section" style="display: none; margin-top: 30px;">
236
+ <h3>Step 2: Assign Splats to Bones</h3>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
 
238
+ <!-- Paint Mode Toggle -->
239
+ <div style="
240
+ margin: 15px 0;
241
+ padding: 10px;
242
+ background: #1a1a2e;
243
+ border-radius: 5px;
244
+ border-left: 3px solid #2196F3;
245
+ ">
246
+ <label style="display: flex; align-items: center; cursor: pointer;">
247
+ <input type="checkbox" id="paint-mode-toggle" style="margin-right: 10px;">
248
+ <span>🎨 <strong>Paint Mode</strong> - Click and drag to paint over selections</span>
249
+ </label>
250
+ <div id="paint-mode-hint" style="
251
+ font-size: 11px;
252
+ color: #aaa;
253
+ margin-top: 5px;
254
+ display: none;
255
  ">
256
+ Hold Shift to erase (unassign splats)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  </div>
258
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
 
260
+ <!-- Preset Selection -->
261
+ <div style="margin: 15px 0;">
262
+ <label style="display: block; margin-bottom: 5px; font-weight: bold;">Assignment Mode:</label>
263
+ <select id="preset-selector" style="
264
+ width: 100%;
265
+ padding: 8px;
266
+ font-size: 14px;
267
  border-radius: 5px;
268
+ background: #333;
269
+ color: white;
270
+ border: 1px solid #555;
271
+ margin-bottom: 10px;
272
  ">
273
+ <option value="required19">✓ Required (19 parts) - All Essential Bones</option>
274
+ </select>
275
+ <div id="preset-description" style="
276
+ font-size: 11px;
277
+ color: #aaa;
278
+ padding: 8px;
 
 
 
 
 
 
 
 
279
  background: #222;
280
  border-radius: 5px;
281
+ margin-bottom: 10px;
282
+ "></div>
283
+ </div>
284
+
285
+ <!-- Bone/Group Selector -->
286
+ <div id="bone-selector-container" style="margin: 15px 0;">
287
+ <label style="display: block; margin-bottom: 5px;">Select Target:</label>
288
+ <select id="bone-selector" style="
289
+ width: 100%;
290
+ padding: 8px;
291
+ font-size: 14px;
292
+ border-radius: 5px;
293
+ background: #333;
294
+ color: white;
295
+ border: 1px solid #555;
296
  ">
297
+ <option value="">-- Select target --</option>
298
+ </select>
299
+ </div>
300
+
301
+ <!-- Selection Tools -->
302
+ <div style="margin: 15px 0;">
303
+ <h4 style="margin-bottom: 10px;">Selection Method:</h4>
304
 
305
+ <div style="margin: 10px 0;">
306
+ <button id="select-sphere-btn" style="
 
307
  padding: 8px 15px;
308
+ background: #FF9800;
309
  color: white;
310
  border: none;
311
  border-radius: 5px;
312
  cursor: pointer;
313
+ width: 100%;
314
+ ">🎯 Select by Sphere (Click on GS)</button>
 
 
 
 
 
 
 
 
 
 
 
315
  </div>
316
 
317
+ <div style="margin: 10px 0;">
318
+ <label>Selection Radius: <span id="selection-radius-value">0.5</span>m</label><br>
319
+ <input type="range" id="selection-radius" min="0.1" max="10.0" step="0.1" value="0.5" style="width: 100%;">
320
+ <div style="font-size: 10px; color: #888; margin-top: 3px;">
321
+ Range: 0.1m - 10m (適切なサイズに調整してください)
322
+ </div>
323
+ </div>
324
+
325
+ <!-- Camera Lock Button -->
326
+ <div style="margin: 15px 0; padding: 10px; background: #1a1a2e; border-radius: 5px;">
327
+ <button id="camera-lock-btn" style="
328
+ padding: 10px 15px;
329
+ background: #9C27B0;
330
  color: white;
331
  border: none;
332
  border-radius: 5px;
333
  cursor: pointer;
 
334
  width: 100%;
335
+ font-weight: bold;
336
+ ">🔓 Camera Unlocked (Can Rotate)</button>
337
+ <div style="font-size: 11px; color: #aaa; margin-top: 5px;">
338
+ Lock camera to prevent accidental movement while painting
339
+ </div>
340
+ </div>
341
+
342
+ <!-- Statistics -->
343
+ <div id="assignment-info" style="
344
+ margin: 15px 0;
345
+ padding: 10px;
346
+ background: #222;
347
+ border-radius: 5px;
348
+ font-size: 12px;
349
+ ">
350
+ <div>Total Splats: <span id="total-splats">0</span></div>
351
+ <div>Assigned: <span id="assigned-splats">0</span></div>
352
+ <div>Unassigned: <span id="unassigned-splats">0</span></div>
353
+ <div style="margin-top: 5px; padding-top: 5px; border-top: 1px solid #444;">
354
+ Progress: <span id="assignment-progress">0%</span>
355
+ </div>
356
+ </div>
357
+
358
+ <!-- Assignment List -->
359
+ <div id="bone-assignment-list" style="
360
+ max-height: 150px;
361
+ overflow-y: auto;
362
+ margin: 15px 0;
363
+ padding: 10px;
364
+ background: #222;
365
+ border-radius: 5px;
366
+ font-size: 11px;
367
+ ">
368
+ <div style="color: #888;">No assignments yet</div>
369
  </div>
370
+
371
+ <!-- Control Buttons -->
372
+ <div style="margin: 15px 0;">
373
+ <button id="clear-selection-btn" style="
374
+ padding: 8px 15px;
375
+ background: #f44336;
376
+ color: white;
377
+ border: none;
378
+ border-radius: 5px;
379
+ cursor: pointer;
380
+ width: 48%;
381
+ margin-right: 2%;
382
+ ">↶ Undo Last</button>
383
+
384
+ <button id="undo-all-btn" style="
385
+ padding: 8px 15px;
386
+ background: #FF5722;
387
+ color: white;
388
+ border: none;
389
+ border-radius: 5px;
390
+ cursor: pointer;
391
+ width: 48%;
392
+ ">⟲ Reset All</button>
393
+ </div>
394
+
395
+ <button id="finalize-btn" style="
396
+ margin-top: 20px;
397
+ padding: 10px 20px;
398
+ background: #2196F3;
399
+ color: white;
400
+ border: none;
401
+ border-radius: 5px;
402
+ cursor: pointer;
403
+ font-size: 16px;
404
+ width: 100%;
405
+ ">✓ Finalize and Save</button>
406
  </div>
407
  `;
408
 
 
409
  document.body.appendChild(uiContainer);
410
 
411
  let boundingBoxHelper = null;
 
446
  if (controlsEl) controlsEl.style.display = 'block';
447
  },
448
 
 
 
449
  createBoundingBox: function(size = { x: 2, y: 2, z: 2 }, position = { x: 0, y: 0, z: 0 }, rotation = { x: 0, y: 0, z: 0 }) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
450
  if (boundingBoxHelper) {
451
  scene.remove(boundingBoxHelper);
452
  }
453
+
454
+ const geometry = new THREE.BoxGeometry(size.x, size.y, size.z);
455
+ const edges = new THREE.EdgesGeometry(geometry);
456
+ const material = new THREE.LineBasicMaterial({ color: 0x00ff00, linewidth: 2 });
457
+ boundingBoxHelper = new THREE.LineSegments(edges, material);
458
+ boundingBoxHelper.position.set(position.x, position.y, position.z);
459
+
460
+ // ⭐ 回転を追加 (Euler angles in radians)
461
+ boundingBoxHelper.rotation.set(rotation.x, rotation.y, rotation.z);
462
+
463
+ scene.add(boundingBoxHelper);
464
+
465
+ return boundingBoxHelper;
466
+ },
467
+
468
+ updateBoundingBox: function(size, position, rotation = { x: 0, y: 0, z: 0 }) {
469
+ if (boundingBoxHelper) {
470
+ scene.remove(boundingBoxHelper);
471
+ }
472
+ return this.createBoundingBox(size, position, rotation);
473
  },
474
 
475
  removeBoundingBox: function() {
 
494
  }
495
  };
496
  }
 
497
  /**
498
  * Bounding Box内のスプラットのみをフィルタリング
499
  */
 
1192
  console.log('[setupBoneAssignment] Starting bone assignment...');
1193
 
1194
  try {
1195
+ ///////////////////
1196
+ // ⭐ オブジェクトのサイズから適切な初期半径を計算
1197
+ function calculateOptimalRadius(filteredGs) {
1198
+ // スプラットの範囲を計算
1199
+ let minX = Infinity, minY = Infinity, minZ = Infinity;
1200
+ let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;
1201
+
1202
+ for (let i = 0; i < filteredGs.splatCount; i++) {
1203
+ const x = filteredGs.centers0[i * 3 + 0];
1204
+ const y = filteredGs.centers0[i * 3 + 1];
1205
+ const z = filteredGs.centers0[i * 3 + 2];
1206
+
1207
+ minX = Math.min(minX, x);
1208
+ minY = Math.min(minY, y);
1209
+ minZ = Math.min(minZ, z);
1210
+ maxX = Math.max(maxX, x);
1211
+ maxY = Math.max(maxY, y);
1212
+ maxZ = Math.max(maxZ, z);
1213
+ }
1214
+
1215
+ // オブジェクトの最大サイズを取得
1216
+ const sizeX = maxX - minX;
1217
+ const sizeY = maxY - minY;
1218
+ const sizeZ = maxZ - minZ;
1219
+ const maxSize = Math.max(sizeX, sizeY, sizeZ);
1220
+
1221
+ // 適切な初期半径 = オブジェクトサイズの5%(調整可能)
1222
+ const optimalRadius = Math.max(0.1, Math.min(10.0, maxSize * 0.05));
1223
+
1224
+ console.log('[calculateOptimalRadius] Object size:', { sizeX, sizeY, sizeZ, maxSize });
1225
+ console.log('[calculateOptimalRadius] Optimal radius:', optimalRadius.toFixed(2), 'm');
1226
+
1227
+ return optimalRadius;
1228
+ }
1229
+
1230
+ // setupBoneAssignment関数内で使用:
1231
+ // let selectionRadius = 0.5; の代わりに:
1232
+ let selectionRadius = calculateOptimalRadius(filteredGs);
1233
+
1234
+ // UIの初期値も更新
1235
+ const selectionRadiusSlider = document.getElementById('selection-radius');
1236
+ const selectionRadiusValue = document.getElementById('selection-radius-value');
1237
+
1238
+ if (selectionRadiusSlider && selectionRadiusValue) {
1239
+ selectionRadiusSlider.value = selectionRadius.toFixed(2);
1240
+ selectionRadiusValue.textContent = selectionRadius.toFixed(2);
1241
+
1242
+ selectionRadiusSlider.addEventListener('input', (e) => {
1243
+ selectionRadius = parseFloat(e.target.value);
1244
+ selectionRadiusValue.textContent = selectionRadius.toFixed(2);
1245
+ });
1246
+ }
1247
+
1248
+ ///////////////////
1249
+
1250
+
1251
  // Load default bone operations
1252
  let response = await fetch("./assets/default.json");
1253
  const params = await response.json();
 
1278
  let selectedTarget = null;
1279
  let currentBoneGroups = PRESET_BONE_GROUPS.required19;
1280
  let selectionMode = null;
1281
+ //let selectionRadius = 0.5;
1282
 
1283
  // ========================================
1284
  // Paint Mode Variables
 
1298
  'required19': 'Required mode: Assign to 20 individual body parts (20-30 min). All bones assigned individually.'
1299
  };
1300
 
1301
+
1302
+
1303
+
1304
+
1305
+
1306
+
1307
  function updateBoneSelector(mode) {
1308
  if (!boneSelector) {
1309
  console.error('[updateBoneSelector] boneSelector not found');
 
1423
  // ========================================
1424
  // Selection Radius
1425
  // ========================================
1426
+ //const selectionRadiusSlider = document.getElementById('selection-radius');
1427
+ //const selectionRadiusValue = document.getElementById('selection-radius-value');
1428
 
1429
  if (selectionRadiusSlider && selectionRadiusValue) {
1430
  selectionRadiusSlider.addEventListener('input', (e) => {
 
1648
  if (intersects.length > 0) {
1649
  const hitPoint = intersects[0].point;
1650
 
1651
+ if (paintModeEraser) {
1652
+ // Erase mode: use full radius for larger objects
1653
+ eraseSplatsInSphere(hitPoint, selectionRadius, true); // 0.5 → 1.0
1654
+ } else {
1655
+ // Paint mode: use full radius for larger objects
1656
+ assignSplatsInSphere(hitPoint, selectionRadius, selectedTarget, true); // 0.5 → 1.0
1657
+ }
1658
  }
1659
  }
1660