def set_planar_viewpoint(vis, camera_position=[0, -1, 0], camera_focus=[0, 0, 0], xmin=-1, xmax=1, ymin=-1, ymax=1): # TODO(russt): Figure out the proper set of camera transformations to # implement camera_focus. if np.any(camera_focus): warnings.warn("Non-zero camera_focus is not supported yet") # Set up orthographic camera. camera = g.OrthographicCamera(left=xmin, right=xmax, top=ymax, bottom=ymin, near=-1000, far=1000) vis['/Cameras/default/rotated'].set_object(camera) vis['/Cameras/default'].set_transform( RigidTransform(camera_position).GetAsMatrix4()) # Lock the orbit controls. vis['/Cameras/default/rotated/<object>'].set_property( "position", [0, 0, 0]) # Turn off background, axes, and grid. vis['/Background'].set_property("visible", False) vis['/Grid'].set_property("visible", False) vis['/Axes'].set_property("visible", False)
def set_planar_viewpoint(self, camera_position=[0, -1, 0], camera_focus=[0, 0, 0], xmin=-1, xmax=1, ymin=-1, ymax=1): """ Sets meshcat to use an orthographic projection with locked out orbit controls, and turns off the background, axes, and grid. This allows meshcat to play a role similar to PlanarSceneGraphVisualizer. Args: camera_position: a 3 element vector specifying the initial xyz location of the camera. camera_focus: a 3 element vector specifying the focal point of the camera. xmin, xmax, ymin, ymax: Scalars specifying the initial view coordinates of the orthographic camera. (Note that xmax is actually ignored because the view is scaled to fit the size of the browser window). Note: The orientation of the camera will be locked, but users can still pan and zoom interactively in the browser. """ # TODO(russt): Figure out the proper set of camera transformations to # implement camera_focus. if np.any(camera_focus): warnings.warn("Non-zero camera_focus is not supported yet") # Set up orthographic camera. camera = g.OrthographicCamera(left=xmin, right=xmax, top=ymax, bottom=ymin, near=-1000, far=1000) self.vis['/Cameras/default/rotated'].set_object(camera) self.vis['/Cameras/default'].set_transform( RigidTransform(camera_position).GetAsMatrix4()) # Lock the orbit controls. self.vis['/Cameras/default/rotated/<object>'].set_property( "position", [0, 0, 0]) # Turn off background, axes, and grid. self.vis['/Background'].set_property("visible", False) self.vis['/Grid'].set_property("visible", False) self.vis['/Axes'].set_property("visible", False)
def runTest(self): """ Test that we can set_object with an OrthographicCamera. """ self.vis.set_object(g.Box([0.5, 0.5, 0.5])) camera = g.OrthographicCamera( left=-1, right=1, bottom=-1, top=1, near=-1000, far=1000) self.vis['/Cameras/default/rotated'].set_object(camera) self.vis['/Cameras/default'].set_transform( tf.translation_matrix([0, -1, 0])) self.vis['/Cameras/default/rotated/<object>'].set_property( "position", [0, 0, 0]) self.vis['/Grid'].set_property("visible", False)