@@ -293,18 +293,10 @@ pub fn set_culling<'gc>(
293
293
if let Some ( context) = this. as_context_3d ( ) {
294
294
let culling = args. get_string ( activation, 0 ) ?;
295
295
296
- let culling = if & * culling == b"none" {
297
- Context3DTriangleFace :: None
298
- } else if & * culling == b"back" {
299
- Context3DTriangleFace :: Back
300
- } else if & * culling == b"front" {
301
- Context3DTriangleFace :: Front
302
- } else if & * culling == b"frontAndBack" {
303
- Context3DTriangleFace :: FrontAndBack
304
- } else {
296
+ let culling = Context3DTriangleFace :: from_wstr ( & culling) . unwrap_or_else ( || {
305
297
tracing:: error!( "Unknown culling {:?}" , culling) ;
306
298
Context3DTriangleFace :: None
307
- } ;
299
+ } ) ;
308
300
309
301
context. set_culling ( culling) ;
310
302
}
@@ -694,45 +686,37 @@ pub fn set_stencil_actions<'gc>(
694
686
let this = this. as_object ( ) . unwrap ( ) ;
695
687
696
688
if let Some ( context) = this. as_context_3d ( ) {
697
- let triangle_face = args. get_string_non_null ( activation, 0 , "triangleFace" ) ?;
689
+ let triangle_face = args. get_string ( activation, 0 ) ?;
698
690
699
- let culling = if & * triangle_face == b"none" {
691
+ let triangle_face = Context3DTriangleFace :: from_wstr ( & triangle_face) . unwrap_or_else ( || {
692
+ tracing:: error!( "Unknown triangle_face {:?}" , triangle_face) ;
700
693
Context3DTriangleFace :: None
701
- } else if & * triangle_face == b"back" {
702
- Context3DTriangleFace :: Back
703
- } else if & * triangle_face == b"front" {
704
- Context3DTriangleFace :: Front
705
- } else if & * triangle_face == b"frontAndBack" {
706
- Context3DTriangleFace :: FrontAndBack
707
- } else {
708
- tracing:: error!( "Unknown culling {:?}" , triangle_face) ;
709
- Context3DTriangleFace :: None
710
- } ;
694
+ } ) ;
711
695
712
696
let compare_mode = args. get_string_non_null ( activation, 1 , "compareMode" ) ?;
713
697
let compare_mode = Context3DCompareMode :: from_wstr ( & compare_mode)
714
698
. ok_or_else ( || make_error_2008 ( activation, "compareMode" ) ) ?;
715
699
716
- let action_on_both_pass = args. get_string_non_null ( activation, 2 , "actionOnBothPass" ) ?;
717
- let action_on_both_pass = Context3DStencilAction :: from_wstr ( & action_on_both_pass )
700
+ let on_both_pass = args. get_string_non_null ( activation, 2 , "actionOnBothPass" ) ?;
701
+ let on_both_pass = Context3DStencilAction :: from_wstr ( & on_both_pass )
718
702
. ok_or_else ( || make_error_2008 ( activation, "actionOnBothPass" ) ) ?;
719
703
720
- let action_on_depth_fail = args. get_string_non_null ( activation, 3 , "actionOnDepthFail" ) ?;
721
- let action_on_depth_fail = Context3DStencilAction :: from_wstr ( & action_on_depth_fail )
704
+ let on_depth_fail = args. get_string_non_null ( activation, 3 , "actionOnDepthFail" ) ?;
705
+ let on_depth_fail = Context3DStencilAction :: from_wstr ( & on_depth_fail )
722
706
. ok_or_else ( || make_error_2008 ( activation, "actionOnDepthFail" ) ) ?;
723
707
724
- let action_on_depth_pass_stencil_fail =
708
+ let on_depth_pass_stencil_fail =
725
709
args. get_string_non_null ( activation, 4 , "actionOnDepthPassStencilFail" ) ?;
726
- let action_on_depth_pass_stencil_fail =
727
- Context3DStencilAction :: from_wstr ( & action_on_depth_pass_stencil_fail )
710
+ let on_depth_pass_stencil_fail =
711
+ Context3DStencilAction :: from_wstr ( & on_depth_pass_stencil_fail )
728
712
. ok_or_else ( || make_error_2008 ( activation, "actionOnDepthPassStencilFail" ) ) ?;
729
713
730
714
context. set_stencil_actions (
731
- culling ,
715
+ triangle_face ,
732
716
compare_mode,
733
- action_on_both_pass ,
734
- action_on_depth_fail ,
735
- action_on_depth_pass_stencil_fail ,
717
+ on_both_pass ,
718
+ on_depth_fail ,
719
+ on_depth_pass_stencil_fail ,
736
720
) ;
737
721
}
738
722
0 commit comments