@@ -55,16 +55,18 @@ pub(crate) fn py_to_shader_value(value: &Bound<'_, PyAny>) -> PyResult<shader_va
5555 ) ) )
5656}
5757
58- // dispatch `albedo=` by python type; may swap the backing asset
5958fn apply_albedo ( entity : Entity , value : & Bound < ' _ , PyAny > ) -> PyResult < ( ) > {
6059 if let Ok ( buf) = value. extract :: < PyRef < Buffer > > ( ) {
6160 return material_set_albedo_buffer ( entity, buf. entity )
6261 . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) ) ;
6362 }
6463 if let Ok ( c) = value. extract :: < PyRef < PyColor > > ( ) {
6564 let srgba: bevy:: color:: Srgba = c. 0 . into ( ) ;
66- return material_set_albedo_color ( entity, [ srgba. red , srgba. green , srgba. blue , srgba. alpha ] )
67- . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) ) ;
65+ return material_set_albedo_color (
66+ entity,
67+ [ srgba. red , srgba. green , srgba. blue , srgba. alpha ] ,
68+ )
69+ . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) ) ;
6870 }
6971 if let Ok ( rgba) = value. extract :: < [ f32 ; 4 ] > ( ) {
7072 return material_set_albedo_color ( entity, rgba)
@@ -95,7 +97,6 @@ fn apply_kwargs(entity: Entity, kwargs: &Bound<'_, PyDict>) -> PyResult<()> {
9597
9698#[ pymethods]
9799impl Material {
98- /// No args: default PBR. With `shader`: custom material. Kwargs are applied via `set`.
99100 #[ new]
100101 #[ pyo3( signature = ( shader=None , * * kwargs) ) ]
101102 pub fn new ( shader : Option < & Shader > , kwargs : Option < & Bound < ' _ , PyDict > > ) -> PyResult < Self > {
@@ -112,7 +113,6 @@ impl Material {
112113 Ok ( Self { entity } )
113114 }
114115
115- /// PBR-lit material. `albedo` accepts a `Color` or a per-particle `Buffer`.
116116 #[ staticmethod]
117117 #[ pyo3( signature = ( * * kwargs) ) ]
118118 pub fn pbr ( kwargs : Option < & Bound < ' _ , PyDict > > ) -> PyResult < Self > {
@@ -123,7 +123,6 @@ impl Material {
123123 Ok ( Self { entity } )
124124 }
125125
126- /// Like `pbr` but skips lighting; albedo is the final output color.
127126 #[ staticmethod]
128127 #[ pyo3( signature = ( * * kwargs) ) ]
129128 pub fn unlit ( kwargs : Option < & Bound < ' _ , PyDict > > ) -> PyResult < Self > {
@@ -136,7 +135,6 @@ impl Material {
136135 Ok ( Self { entity } )
137136 }
138137
139- /// Set material properties. `albedo` may swap the backing asset; other fields are preserved.
140138 #[ pyo3( signature = ( * * kwargs) ) ]
141139 pub fn set ( & self , kwargs : Option < & Bound < ' _ , PyDict > > ) -> PyResult < ( ) > {
142140 let Some ( kwargs) = kwargs else {
0 commit comments