()
| 95 | |
| 96 | |
| 97 | def normalize_scene(): |
| 98 | bbox_min, bbox_max = scene_bbox() |
| 99 | scale = 1 / max(bbox_max - bbox_min) |
| 100 | |
| 101 | for obj in scene_root_objects(): |
| 102 | obj.scale = obj.scale * scale |
| 103 | |
| 104 | # Apply scale to matrix_world. |
| 105 | bpy.context.view_layer.update() |
| 106 | |
| 107 | bbox_min, bbox_max = scene_bbox() |
| 108 | offset = -(bbox_min + bbox_max) / 2 |
| 109 | for obj in scene_root_objects(): |
| 110 | obj.matrix_world.translation += offset |
| 111 | |
| 112 | bpy.ops.object.select_all(action="DESELECT") |
| 113 | |
| 114 | |
| 115 | def create_camera(): |
no test coverage detected