stpete2 commited on
Commit
3f2cecb
·
verified ·
1 Parent(s): 15f71d4

Upload preprocess_manual.js

Browse files
Files changed (1) hide show
  1. preprocess_manual.js +100 -20
preprocess_manual.js CHANGED
@@ -162,23 +162,23 @@ function createManualUI(scene, camera, renderer) {
162
  Adjust the box to include only the person
163
  </p>
164
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
 
166
- <div style="margin: 10px 0;">
167
- <label>X Size: <span id="box-x-value">10.0</span>m</label><br>
168
- <input type="range" id="box-x" min="0.5" max="10.0" step="0.1" value="10.0" style="width: 100%;">
169
- </div>
170
- <div style="margin: 10px 0;">
171
- <label>Y Size: <span id="box-y-value">10.0</span>m</label><br>
172
- <input type="range" id="box-y" min="0.5" max="10.0" step="0.1" value="10.0" style="width: 100%;">
173
- </div>
174
- <div style="margin: 10px 0;">
175
- <label>Z Size: <span id="box-z-value">10.0</span>m</label><br>
176
- <input type="range" id="box-z" min="0.5" max="10.0" step="0.1" value="10.0" style="width: 100%;">
177
- </div>
178
- <div style="margin: 10px 0;">
179
- <label>Y Position: <span id="box-y-pos-value">0.0</span>m</label><br>
180
- <input type="range" id="box-y-pos" min="-10.0" max="10.0" step="0.1" value="10.0" style="width: 100%;">
181
- </div>
182
 
183
  <div style="margin: 10px 0;">
184
  // ==========================================
@@ -755,12 +755,56 @@ export function preprocessManual(vrmPath, gsPath, scene, camera, renderer, stage
755
  let loadingSpinner = new DropInViewer().viewer.loadingSpinner;
756
  const task = loadingSpinner.addTask('Loading PLY...');
757
 
 
 
 
758
  parser.parsePLY(gsPath, true).then((plyData) => {
759
  console.log('[preprocessManual] PLY loaded:', plyData.vertices.length, 'vertices');
760
  loadingSpinner.removeTask(task);
761
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
762
  // GSの初期表示, replace all 20251207
763
- GVRM.initGS(gsPath, undefined, undefined, scene).then((gs) => {
764
  console.log('[preprocessManual] GS initialized');
765
 
766
  // ★★★ ADD CAMERA CONTROLS HERE ★★★
@@ -893,10 +937,43 @@ export function preprocessManual(vrmPath, gsPath, scene, camera, renderer, stage
893
  }
894
  animateBoxAdjustment();
895
 
896
- let boxSize = { x: 2, y: 2, z: 2 };
897
- let boxPosition = { x: 0, y: 0, z: 0 };
898
- ui.createBoundingBox(boxSize, boxPosition);
 
 
 
 
 
 
 
 
899
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
900
  // Box sliders setup
901
  const setupBoxSlider = (id, valueId, property, isPosition = false) => {
902
  const slider = document.getElementById(id);
@@ -1016,6 +1093,9 @@ export function preprocessManual(vrmPath, gsPath, scene, camera, renderer, stage
1016
  });
1017
  });
1018
 
 
 
 
1019
  }).catch(err => {
1020
  console.error('[preprocessManual] UI init error:', err);
1021
  resolve({
 
162
  Adjust the box to include only the person
163
  </p>
164
 
165
+ <div style="margin: 10px 0;">
166
+ <label>X Size: <span id="box-x-value">Auto</span>m</label><br>
167
+ <input type="range" id="box-x" min="0.5" max="20.0" step="0.1" value="2.0" style="width: 100%;">
168
+ </div>
169
+ <div style="margin: 10px 0;">
170
+ <label>Y Size: <span id="box-y-value">Auto</span>m</label><br>
171
+ <input type="range" id="box-y" min="0.5" max="20.0" step="0.1" value="2.0" style="width: 100%;">
172
+ </div>
173
+ <div style="margin: 10px 0;">
174
+ <label>Z Size: <span id="box-z-value">Auto</span>m</label><br>
175
+ <input type="range" id="box-z" min="0.5" max="20.0" step="0.1" value="2.0" style="width: 100%;">
176
+ </div>
177
+ <div style="margin: 10px 0;">
178
+ <label>Y Position: <span id="box-y-pos-value">Auto</span>m</label><br>
179
+ <input type="range" id="box-y-pos" min="-20.0" max="20.0" step="0.1" value="0.0" style="width: 100%;">
180
+ </div>
181
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
 
183
  <div style="margin: 10px 0;">
184
  // ==========================================
 
755
  let loadingSpinner = new DropInViewer().viewer.loadingSpinner;
756
  const task = loadingSpinner.addTask('Loading PLY...');
757
 
758
+
759
+ ///////////////////////12/13 15:20
760
+
761
  parser.parsePLY(gsPath, true).then((plyData) => {
762
  console.log('[preprocessManual] PLY loaded:', plyData.vertices.length, 'vertices');
763
  loadingSpinner.removeTask(task);
764
 
765
+ // ========================================
766
+ // Calculate Bounding Box from PLY data
767
+ // ========================================
768
+ let minX = Infinity, minY = Infinity, minZ = Infinity;
769
+ let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;
770
+
771
+ plyData.vertices.forEach(vertex => {
772
+ minX = Math.min(minX, vertex.x);
773
+ minY = Math.min(minY, vertex.y);
774
+ minZ = Math.min(minZ, vertex.z);
775
+ maxX = Math.max(maxX, vertex.x);
776
+ maxY = Math.max(maxY, vertex.y);
777
+ maxZ = Math.max(maxZ, vertex.z);
778
+ });
779
+
780
+ // Calculate size and center
781
+ const sizeX = maxX - minX;
782
+ const sizeY = maxY - minY;
783
+ const sizeZ = maxZ - minZ;
784
+ const centerX = (maxX + minX) / 2;
785
+ const centerY = (maxY + minY) / 2;
786
+ const centerZ = (maxZ + minZ) / 2;
787
+
788
+ // Add 20% margin for safety
789
+ const margin = 1.2;
790
+ const defaultBoxSize = {
791
+ x: sizeX * margin,
792
+ y: sizeY * margin,
793
+ z: sizeZ * margin
794
+ };
795
+ const defaultBoxPosition = {
796
+ x: centerX,
797
+ y: centerY,
798
+ z: centerZ
799
+ };
800
+
801
+ console.log('[preprocessManual] Calculated bounding box:');
802
+ console.log(' Size:', defaultBoxSize);
803
+ console.log(' Center:', defaultBoxPosition);
804
+ console.log(' Raw size:', { x: sizeX, y: sizeY, z: sizeZ });
805
+
806
  // GSの初期表示, replace all 20251207
807
+ GVRM.initGS(gsPath, undefined, undefined, scene).then((gs) => {
808
  console.log('[preprocessManual] GS initialized');
809
 
810
  // ★★★ ADD CAMERA CONTROLS HERE ★★★
 
937
  }
938
  animateBoxAdjustment();
939
 
940
+ ///////////////////////////////////// 12/13 15:40 START
941
+
942
+ // Use calculated bounding box
943
+ let boxSize = { ...defaultBoxSize };
944
+ let boxPosition = { ...defaultBoxPosition };
945
+ ui.createBoundingBox(boxSize, boxPosition);
946
+
947
+ // Update UI sliders with calculated values
948
+ const updateSliderRange = (id, valueId, value, size) => {
949
+ const slider = document.getElementById(id);
950
+ const valueDisplay = document.getElementById(valueId);
951
 
952
+ if (slider && valueDisplay) {
953
+ // Set max to 2x the calculated size
954
+ slider.max = (size * 2).toFixed(1);
955
+ slider.value = value.toFixed(1);
956
+ valueDisplay.textContent = value.toFixed(1);
957
+ }
958
+ };
959
+
960
+ // Update size sliders
961
+ updateSliderRange('box-x', 'box-x-value', boxSize.x, defaultBoxSize.x);
962
+ updateSliderRange('box-y', 'box-y-value', boxSize.y, defaultBoxSize.y);
963
+ updateSliderRange('box-z', 'box-z-value', boxSize.z, defaultBoxSize.z);
964
+
965
+ // Update position slider
966
+ const boxYPosSlider = document.getElementById('box-y-pos');
967
+ const boxYPosValue = document.getElementById('box-y-pos-value');
968
+ if (boxYPosSlider && boxYPosValue) {
969
+ boxYPosSlider.min = (defaultBoxPosition.y - defaultBoxSize.y).toFixed(1);
970
+ boxYPosSlider.max = (defaultBoxPosition.y + defaultBoxSize.y).toFixed(1);
971
+ boxYPosSlider.value = boxPosition.y.toFixed(1);
972
+ boxYPosValue.textContent = boxPosition.y.toFixed(1);
973
+ }
974
+
975
+ ///////////////////////////////////// 12/13 15:40 END
976
+
977
  // Box sliders setup
978
  const setupBoxSlider = (id, valueId, property, isPosition = false) => {
979
  const slider = document.getElementById(id);
 
1093
  });
1094
  });
1095
 
1096
+
1097
+
1098
+
1099
  }).catch(err => {
1100
  console.error('[preprocessManual] UI init error:', err);
1101
  resolve({