(location, energy=1.0, angle=0.5 * math.pi / 180)
| 161 | |
| 162 | |
| 163 | def create_light(location, energy=1.0, angle=0.5 * math.pi / 180): |
| 164 | # https://blender.stackexchange.com/questions/215624/how-to-create-a-light-with-the-python-api-in-blender-2-92 |
| 165 | light_data = bpy.data.lights.new(name="Light", type="SUN") |
| 166 | light_data.energy = energy |
| 167 | light_data.angle = angle |
| 168 | light_object = bpy.data.objects.new(name="Light", object_data=light_data) |
| 169 | |
| 170 | direction = -location |
| 171 | rot_quat = direction.to_track_quat("-Z", "Y") |
| 172 | light_object.rotation_euler = rot_quat.to_euler() |
| 173 | bpy.context.view_layer.update() |
| 174 | |
| 175 | bpy.context.collection.objects.link(light_object) |
| 176 | light_object.location = location |
| 177 | |
| 178 | |
| 179 | def create_random_lights(count=4, distance=2.0, energy=1.5): |
no outgoing calls
no test coverage detected