I am writing a script that randomizes camera position in relation to a single object, but most of the time when I render the object is not in view so I get the plain grey background. I think there is a flaw in the class that reorients the camera so that the object is within the frame. Can help me? Here is the class meant to point the camera back towards the object. I am on blender version 2.81.16, which is the latest version that is compatible with a plug in I need.
def point_camera(camera, point=(0., 0., 0.)): """ point camera to 'location' looking directly at origin args: location: list of 3 representing the location to point at origin: list of floats that represent where the camera will be looking at returns: None """ point = Vector(point) camera_location = camera.location direction = point - camera_location quaternion_rotation = direction.to_track_quat('-Z', 'Y') euler_rotation = quaternion_rotation.to_euler() camera.rotation_euler = euler_rotation