abreza commited on
Commit
a202f8d
1 Parent(s): 247f6df

Enhance log_simulation function with color support for vertices and camera trajectory

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import json
2
  import numpy as np
3
  import rerun as rr
4
- from rerun.components import Material
5
  import spaces
6
  import gradio as gr
7
  from gradio_rerun import Rerun
@@ -81,7 +80,8 @@ def log_simulation(simulation_data: Dict[str, Any]) -> None:
81
  rr.Mesh3D(
82
  vertex_positions=vertices,
83
  indices=faces,
84
- mesh_material=Material(albedo_factor=subject_color)
 
85
  ),
86
  timeless=True
87
  )
@@ -96,11 +96,15 @@ def log_simulation(simulation_data: Dict[str, Any]) -> None:
96
  [vector3_to_numpy(frame['position']) for frame in camera_frames])
97
  rr.log(
98
  "world/camera_trajectory",
99
- rr.Points3D(camera_positions),
 
 
 
 
100
  timeless=True
101
  )
102
 
103
- # Log camera positions over time
104
  for frame_idx, camera_frame in enumerate(camera_frames):
105
  rr.set_time_sequence("frame", frame_idx)
106
 
@@ -126,6 +130,12 @@ def log_simulation(simulation_data: Dict[str, Any]) -> None:
126
  )
127
  )
128
 
 
 
 
 
 
 
129
 
130
  def load_simulation_data(file) -> Tuple[Optional[List[Dict[str, Any]]], Optional[List[str]]]:
131
  """Load simulation data from JSON file and return simulations with their descriptions"""
 
1
  import json
2
  import numpy as np
3
  import rerun as rr
 
4
  import spaces
5
  import gradio as gr
6
  from gradio_rerun import Rerun
 
80
  rr.Mesh3D(
81
  vertex_positions=vertices,
82
  indices=faces,
83
+ # Apply color to all vertices
84
+ colors=np.tile(subject_color, (len(vertices), 1))
85
  ),
86
  timeless=True
87
  )
 
96
  [vector3_to_numpy(frame['position']) for frame in camera_frames])
97
  rr.log(
98
  "world/camera_trajectory",
99
+ rr.Points3D(
100
+ camera_positions,
101
+ # Cyan color for trajectory
102
+ colors=np.full((len(camera_positions), 4), [0.0, 0.8, 0.8, 1.0])
103
+ ),
104
  timeless=True
105
  )
106
 
107
+ # Log camera movement over time
108
  for frame_idx, camera_frame in enumerate(camera_frames):
109
  rr.set_time_sequence("frame", frame_idx)
110
 
 
130
  )
131
  )
132
 
133
+ # Log frame number
134
+ rr.log(
135
+ "metadata/current_frame",
136
+ rr.TextDocument(f"Frame: {frame_idx + 1}/{len(camera_frames)}"),
137
+ )
138
+
139
 
140
  def load_simulation_data(file) -> Tuple[Optional[List[Dict[str, Any]]], Optional[List[str]]]:
141
  """Load simulation data from JSON file and return simulations with their descriptions"""