@@ -485,8 +485,8 @@ pub fn js_shear_y(graphics_id: BigInt, angle: f64) -> Result<()> {
485485pub fn js_set_blend_mode ( graphics_id : BigInt , mode : u8 ) -> Result < ( ) > {
486486 let graphics = ent ( graphics_id) ;
487487 check ( ( || {
488- let blend_state = BlendMode :: try_from ( mode) ?. to_blend_state ( ) ;
489- graphics_record_command ( graphics, DrawCommand :: BlendMode ( blend_state ) )
488+ let blend = BlendMode :: try_from ( mode) ?. to_blend ( ) ;
489+ graphics_record_command ( graphics, DrawCommand :: BlendMode ( blend ) )
490490 } ) ( ) )
491491}
492492
@@ -505,7 +505,10 @@ pub fn js_set_custom_blend_mode(
505505 let blend_state = custom_blend_state (
506506 color_src, color_dst, color_op, alpha_src, alpha_dst, alpha_op,
507507 ) ?;
508- graphics_record_command ( graphics, DrawCommand :: BlendMode ( Some ( blend_state) ) )
508+ graphics_record_command (
509+ graphics,
510+ DrawCommand :: BlendMode ( Some ( Blend :: Equation ( blend_state) ) ) ,
511+ )
509512 } ) ( ) )
510513}
511514
@@ -2088,9 +2091,29 @@ pub fn js_material(graphics_id: BigInt, mat_id: BigInt) -> Result<()> {
20882091 record ( graphics_id, DrawCommand :: Material ( ent ( mat_id) ) )
20892092}
20902093
2091- #[ napi( js_name = "materialSetAlphaMode" ) ]
2092- pub fn js_material_set_alpha_mode ( mat_id : BigInt , mode : u8 , cutoff : f64 ) -> Result < ( ) > {
2093- check ( material_set_alpha_mode ( ent ( mat_id) , mode, cutoff as f32 ) )
2094+ #[ napi( js_name = "materialSetMask" ) ]
2095+ pub fn js_material_set_mask ( mat_id : BigInt , cutoff : f64 ) -> Result < ( ) > {
2096+ check ( material_set_mask ( ent ( mat_id) , Some ( cutoff as f32 ) ) )
2097+ }
2098+
2099+ #[ napi( js_name = "materialNoMask" ) ]
2100+ pub fn js_material_no_mask ( mat_id : BigInt ) -> Result < ( ) > {
2101+ check ( material_set_mask ( ent ( mat_id) , None ) )
2102+ }
2103+
2104+ #[ napi( js_name = "materialSetBlendMode" ) ]
2105+ pub fn js_material_set_blend_mode ( mat_id : BigInt , mode : u8 ) -> Result < ( ) > {
2106+ let mat = ent ( mat_id) ;
2107+ check ( ( || {
2108+ let blend = BlendMode :: try_from ( mode) ?. to_material_blend ( ) ;
2109+ material_set_blend_mode ( mat, Some ( blend) )
2110+ } ) ( ) )
2111+ }
2112+
2113+ /// The material follows the current blend mode again.
2114+ #[ napi( js_name = "materialNoBlendMode" ) ]
2115+ pub fn js_material_no_blend_mode ( mat_id : BigInt ) -> Result < ( ) > {
2116+ check ( material_set_blend_mode ( ent ( mat_id) , None ) )
20942117}
20952118
20962119#[ napi( js_name = "materialSetDoubleSided" ) ]
@@ -2123,7 +2146,7 @@ pub fn js_material_set_custom_blend_mode(
21232146 let blend_state = custom_blend_state (
21242147 color_src, color_dst, color_op, alpha_src, alpha_dst, alpha_op,
21252148 ) ?;
2126- material_set_custom_blend ( mat, blend_state)
2149+ material_set_blend_mode ( mat, Some ( Blend :: Equation ( blend_state) ) )
21272150 } ) ( ) )
21282151}
21292152
0 commit comments