@@ -1370,46 +1370,74 @@ mod mewnala {
13701370 graphics. create_image ( width, height)
13711371 }
13721372
1373+ fn apply_light_transform (
1374+ light : & Light ,
1375+ position : Option < super :: math:: Vec3Like > ,
1376+ look_at : Option < super :: math:: Vec3Like > ,
1377+ ) -> PyResult < ( ) > {
1378+ if let Some ( p) = position {
1379+ :: processing:: prelude:: transform_set_position ( light. entity , p. into_vec3 ( ) )
1380+ . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) ) ?;
1381+ }
1382+ if let Some ( la) = look_at {
1383+ :: processing:: prelude:: transform_look_at ( light. entity , la. into_vec3 ( ) )
1384+ . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) ) ?;
1385+ }
1386+ Ok ( ( ) )
1387+ }
1388+
13731389 #[ pyfunction]
1374- #[ pyo3( pass_module) ]
1375- fn create_directional_light (
1390+ #[ pyo3( pass_module, signature = ( color , illuminance , * , position= None , look_at= None ) ) ]
1391+ fn directional_light (
13761392 module : & Bound < ' _ , PyModule > ,
13771393 color : super :: color:: ColorLike ,
13781394 illuminance : f32 ,
1395+ position : Option < super :: math:: Vec3Like > ,
1396+ look_at : Option < super :: math:: Vec3Like > ,
13791397 ) -> PyResult < Light > {
13801398 let graphics =
13811399 get_graphics ( module) ?. ok_or_else ( || PyRuntimeError :: new_err ( "call size() first" ) ) ?;
1382- graphics. light_directional ( color, illuminance)
1400+ let light = graphics. light_directional ( color, illuminance) ?;
1401+ apply_light_transform ( & light, position, look_at) ?;
1402+ Ok ( light)
13831403 }
13841404
13851405 #[ pyfunction]
1386- #[ pyo3( pass_module) ]
1387- fn create_point_light (
1406+ #[ pyo3( pass_module, signature = ( color , intensity , range , radius , * , position= None , look_at= None ) ) ]
1407+ fn point_light (
13881408 module : & Bound < ' _ , PyModule > ,
13891409 color : super :: color:: ColorLike ,
13901410 intensity : f32 ,
13911411 range : f32 ,
13921412 radius : f32 ,
1413+ position : Option < super :: math:: Vec3Like > ,
1414+ look_at : Option < super :: math:: Vec3Like > ,
13931415 ) -> PyResult < Light > {
13941416 let graphics =
13951417 get_graphics ( module) ?. ok_or_else ( || PyRuntimeError :: new_err ( "call size() first" ) ) ?;
1396- graphics. light_point ( color, intensity, range, radius)
1418+ let light = graphics. light_point ( color, intensity, range, radius) ?;
1419+ apply_light_transform ( & light, position, look_at) ?;
1420+ Ok ( light)
13971421 }
13981422
13991423 #[ pyfunction]
1400- #[ pyo3( pass_module) ]
1401- fn create_spot_light (
1424+ #[ pyo3( pass_module, signature = ( color , intensity , range , radius , inner_angle , outer_angle , * , position= None , look_at= None ) ) ]
1425+ fn spot_light (
14021426 module : & Bound < ' _ , PyModule > ,
14031427 color : super :: color:: ColorLike ,
14041428 intensity : f32 ,
14051429 range : f32 ,
14061430 radius : f32 ,
14071431 inner_angle : f32 ,
14081432 outer_angle : f32 ,
1433+ position : Option < super :: math:: Vec3Like > ,
1434+ look_at : Option < super :: math:: Vec3Like > ,
14091435 ) -> PyResult < Light > {
14101436 let graphics =
14111437 get_graphics ( module) ?. ok_or_else ( || PyRuntimeError :: new_err ( "call size() first" ) ) ?;
1412- graphics. light_spot ( color, intensity, range, radius, inner_angle, outer_angle)
1438+ let light = graphics. light_spot ( color, intensity, range, radius, inner_angle, outer_angle) ?;
1439+ apply_light_transform ( & light, position, look_at) ?;
1440+ Ok ( light)
14131441 }
14141442
14151443 #[ pyfunction( name = "sphere" ) ]
0 commit comments