MySafeCode commited on
Commit
a679d69
·
verified ·
1 Parent(s): 39806b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -14
app.py CHANGED
@@ -192,9 +192,8 @@ def process_vox_file(vox_file) -> Tuple[str, str]:
192
  except Exception as e:
193
  return "", f"Error: {str(e)}"
194
 
195
- # GLB Preview Component
196
  def create_glb_preview(glb_file):
197
- """Create HTML preview for GLB file"""
198
  if glb_file is None:
199
  return "<p>No GLB file to preview</p>"
200
 
@@ -206,7 +205,7 @@ def create_glb_preview(glb_file):
206
  if not os.path.exists(glb_path):
207
  return "<p>GLB file not found</p>"
208
 
209
- # Create HTML with Three.js viewer
210
  html_content = f"""
211
  <div style="width: 100%; height: 400px; position: relative; background: #1a1a1a; border-radius: 8px; overflow: hidden;">
212
  <div id="preview-container" style="width: 100%; height: 100%;"></div>
@@ -228,7 +227,7 @@ def create_glb_preview(glb_file):
228
  const camera = new THREE.PerspectiveCamera(75, container.clientWidth / container.clientHeight, 0.1, 1000);
229
  camera.position.set(5, 5, 5);
230
 
231
- const renderer = new THREE.WebGLRenderer({ antialias: true });
232
  renderer.setSize(container.clientWidth, container.clientHeight);
233
  renderer.setPixelRatio(window.devicePixelRatio);
234
  renderer.shadowMap.enabled = true;
@@ -260,7 +259,7 @@ def create_glb_preview(glb_file):
260
 
261
  loader.load(
262
  glbPath,
263
- function (gltf) {
264
  const model = gltf.scene;
265
 
266
  // Center and scale the model
@@ -279,7 +278,7 @@ def create_glb_preview(glb_file):
279
  scene.add(model);
280
 
281
  // Auto-rotate camera
282
- function animate() {
283
  requestAnimationFrame(animate);
284
  controls.update();
285
 
@@ -290,24 +289,24 @@ def create_glb_preview(glb_file):
290
  camera.lookAt(0, 0, 0);
291
 
292
  renderer.render(scene, camera);
293
- }
294
  animate();
295
- },
296
- function (progress) {
297
  console.log('Loading:', progress);
298
- },
299
- function (error) {
300
  console.error('Error loading GLB:', error);
301
  container.innerHTML = '<p style="color: white; text-align: center; padding: 20px;">Error loading GLB file</p>';
302
- }
303
  );
304
 
305
  // Handle resize
306
- window.addEventListener('resize', function() {
307
  camera.aspect = container.clientWidth / container.clientHeight;
308
  camera.updateProjectionMatrix();
309
  renderer.setSize(container.clientWidth, container.clientHeight);
310
- });
311
  </script>
312
  """
313
 
 
192
  except Exception as e:
193
  return "", f"Error: {str(e)}"
194
 
 
195
  def create_glb_preview(glb_file):
196
+ """Create HTML preview for GLB file - FIXED SYNTAX ERROR"""
197
  if glb_file is None:
198
  return "<p>No GLB file to preview</p>"
199
 
 
205
  if not os.path.exists(glb_path):
206
  return "<p>GLB file not found</p>"
207
 
208
+ # Create HTML with Three.js viewer - FIXED THE SYNTAX ERROR
209
  html_content = f"""
210
  <div style="width: 100%; height: 400px; position: relative; background: #1a1a1a; border-radius: 8px; overflow: hidden;">
211
  <div id="preview-container" style="width: 100%; height: 100%;"></div>
 
227
  const camera = new THREE.PerspectiveCamera(75, container.clientWidth / container.clientHeight, 0.1, 1000);
228
  camera.position.set(5, 5, 5);
229
 
230
+ const renderer = new THREE.WebGLRenderer({{ antialias: true }});
231
  renderer.setSize(container.clientWidth, container.clientHeight);
232
  renderer.setPixelRatio(window.devicePixelRatio);
233
  renderer.shadowMap.enabled = true;
 
259
 
260
  loader.load(
261
  glbPath,
262
+ function (gltf) {{
263
  const model = gltf.scene;
264
 
265
  // Center and scale the model
 
278
  scene.add(model);
279
 
280
  // Auto-rotate camera
281
+ function animate() {{
282
  requestAnimationFrame(animate);
283
  controls.update();
284
 
 
289
  camera.lookAt(0, 0, 0);
290
 
291
  renderer.render(scene, camera);
292
+ }}
293
  animate();
294
+ }},
295
+ function (progress) {{
296
  console.log('Loading:', progress);
297
+ }},
298
+ function (error) {{
299
  console.error('Error loading GLB:', error);
300
  container.innerHTML = '<p style="color: white; text-align: center; padding: 20px;">Error loading GLB file</p>';
301
+ }}
302
  );
303
 
304
  // Handle resize
305
+ window.addEventListener('resize', function() {{
306
  camera.aspect = container.clientWidth / container.clientHeight;
307
  camera.updateProjectionMatrix();
308
  renderer.setSize(container.clientWidth, container.clientHeight);
309
+ }});
310
  </script>
311
  """
312