Fixes and ui updates

This commit is contained in:
Matt Tancik authored and Matthew Tancik committed 2022-07-22 20:01:25 -07:00
1 parent 19bc554a0c
commit f7acc3f837
3 files changed
+29 -7

No files matched your search

+2 -2
View File
@@ -59,7 +59,7 @@ def get_camera_wireframe(scale: float = 0.3, f: int = 4, w: int = 1.5, h: int =
ll = np.array([-w, -h, -f]) ll = np.array([-w, -h, -f])
lr = np.array([w, -h, -f]) lr = np.array([w, -h, -f])
C = np.zeros(3) C = np.zeros(3)
camera_points = [C, ul, C, ur, C, ll, C, lr, C] camera_points = [C, ul, C, ur, C, ll, C, lr, C, ul, ur, ul, lr, ur, lr, ll, ll, ul]
lines = np.stack(camera_points) * scale lines = np.stack(camera_points) * scale
return lines return lines
@@ -131,6 +131,6 @@ def frustum(
colors = np.array([color for _ in range(N)]) colors = np.array([color for _ in range(N)])
line_segments = LineSegments( line_segments = LineSegments(
PointsGeometry(position=camera_wireframe_lines.astype(np.float32).T, color=colors.astype(np.float32).T), PointsGeometry(position=camera_wireframe_lines.astype(np.float32).T, color=colors.astype(np.float32).T),
LineBasicMaterial(vertexColors=True, linewidth=10.0), LineBasicMaterial(vertexColors=True),
) )
return line_segments return line_segments
+2 -1
View File
@@ -393,7 +393,8 @@ class Object(SceneElement):
self.material = material self.material = material
self._type = self._type self._type = self._type
def lower(self, object_data): # pylint: arguments-differ
def lower(self):
data = { data = {
"metadata": { "metadata": {
"version": 4.5, "version": 4.5,
+25 -4
View File
@@ -276,9 +276,9 @@ class VisualizerState:
set_output_options(self.vis, list(outputs.keys())) set_output_options(self.vis, list(outputs.keys()))
self.outputs_set = True self.outputs_set = True
# gross hack to get the image key, depending on which keys the graph uses # gross hack to get the image key, depending on which keys the graph uses
if output_type == "default": if self.prev_output_type == "default":
output_type = "rgb" if "rgb" in outputs else "rgb_fine" self.prev_output_type = "rgb" if "rgb" in outputs else "rgb_fine"
image_output = outputs[output_type].cpu().numpy() * 255 image_output = outputs[self.prev_output_type].cpu().numpy() * 255
image = (image_output).astype("uint8") image = (image_output).astype("uint8")
self.vis["/Cameras/Main Camera"].set_image(image) self.vis["/Cameras/Main Camera"].set_image(image)
@@ -526,6 +526,27 @@ def set_camera(vis, camera: Camera):
def draw_aabb(vis, aabb, name="aabb"): def draw_aabb(vis, aabb, name="aabb"):
"""Draw the axis-aligned bounding box.""" """Draw the axis-aligned bounding box."""
lengths = aabb[1] - aabb[0] lengths = aabb[1] - aabb[0]
vis[name].set_object(g.Box(lengths.tolist()), material=g.MeshPhongMaterial(color=0xFF0000, opacity=0.1))
w = 1
aaa = np.array([w, w, w])
aab = np.array([w, w, -w])
aba = np.array([w, -w, w])
baa = np.array([-w, w, w])
abb = np.array([w, -w, -w])
bba = np.array([-w, -w, w])
bab = np.array([-w, w, -w])
bbb = np.array([-w, -w, -w])
camera_points = [aaa, aab, aaa, aba, aab, abb, aba, abb]
camera_points.extend([baa, bab, baa, bba, bab, bbb, bba, bbb])
camera_points.extend([aaa, baa, aab, bab, aba, bba, abb, bbb])
lines = np.stack(camera_points)
lines = lines * np.array(lengths) / 2.0
line_segments = g.LineSegments(
g.PointsGeometry(position=lines.astype(np.float32).T),
g.LineBasicMaterial(vertexColors=True),
)
vis[name].set_object(line_segments)
center = aabb[0] + lengths / 2.0 center = aabb[0] + lengths / 2.0
vis[name].set_transform(get_translation_matrix(center.tolist())) vis[name].set_transform(get_translation_matrix(center.tolist()))