fn draw_environment(&self, render_scene_index: u32) {
        let frame = &self.current_frame.as_ref().unwrap();

        let perspective = match frame.transform {
            RenderTransform::Transform2D(..) => return,
            RenderTransform::Perspective(perspective) => perspective,
        };

        if self.ui_model.background_color == BackgroundColor::Transparent {
            return;
        }

        let ground_scale = self.scene_metadata.view_box.max_x() * 2.0;

        let mut offset = self.scene_metadata.view_box.lower_right().to_4d();
        offset.set_z(ground_scale);
        offset = offset * Vector4F::new(-0.5, 1.0, -0.5, 1.0);
        let base_transform = perspective.transform * Transform4F::from_translation(offset);

        // Fill ground.
        let transform = base_transform *    
            Transform4F::from_scale(Vector4F::new(ground_scale, 1.0, ground_scale, 1.0));

        // Don't clear the first scene after drawing it.
        let clear_color = if render_scene_index == 0 {
            Some(self.background_color().to_f32())
        } else {
            None
        };

        self.renderer.device.draw_elements(6, &RenderState {
            target: &self.renderer.draw_render_target(),
            program: &self.ground_program.program,
            vertex_array: &self.ground_vertex_array.vertex_array,
            primitive: Primitive::Triangles,
            textures: &[],
            uniforms: &[
                (&self.ground_program.transform_uniform,
                 UniformData::from_transform_3d(&transform)),
                (&self.ground_program.ground_color_uniform,
                 UniformData::Vec4(GROUND_SOLID_COLOR.to_f32().0)),
                (&self.ground_program.gridline_color_uniform,
                 UniformData::Vec4(GROUND_LINE_COLOR.to_f32().0)),
                (&self.ground_program.gridline_count_uniform, UniformData::Int(GRIDLINE_COUNT)),
            ],
            viewport: self.renderer.draw_viewport(),
            options: RenderOptions {
                depth: Some(DepthState { func: DepthFunc::Less, write: true }),
                clear_ops: ClearOps { color: clear_color, depth: Some(1.0), stencil: Some(0) },
                ..RenderOptions::default()
            },
        });
    }
// Draws the ground, if applicable.
Draws the ground, if applicable.
Draws the ground if applicable .
fn draw_environment(&self, render_scene_index: u32) {
        let frame = &self.current_frame.as_ref().unwrap();
        let perspective = match frame.transform {
            RenderTransform::Transform2D(..) => return,
            RenderTransform::Perspective(perspective) => perspective,
        };
        if self.ui_model.background_color == BackgroundColor::Transparent {
            return;
        }
        let ground_scale = self.scene_metadata.view_box.max_x() * 2.0;
        let mut offset = self.scene_metadata.view_box.lower_right().to_4d();
        offset.set_z(ground_scale);
        offset = offset * Vector4F::new(-0.5, 1.0, -0.5, 1.0);
        let base_transform = perspective.transform * Transform4F::from_translation(offset);
        // Fill ground.
        let transform = base_transform *    
            Transform4F::from_scale(Vector4F::new(ground_scale, 1.0, ground_scale, 1.0));
        // Don't clear the first scene after drawing it.
        let clear_color = if render_scene_index == 0 {
            Some(self.background_color().to_f32())
        } else {
            None
        };
        self.renderer.device.draw_elements(6, &RenderState {
            target: &self.renderer.draw_render_target(),
            program: &self.ground_program.program,
            vertex_array: &self.ground_vertex_array.vertex_array,
            primitive: Primitive::Triangles,
            textures: &[],
            uniforms: &[
                (&self.ground_program.transform_uniform,
                 UniformData::from_transform_3d(&transform)),
                (&self.ground_program.ground_color_uniform,
                 UniformData::Vec4(GROUND_SOLID_COLOR.to_f32().0)),
                (&self.ground_program.gridline_color_uniform,
                 UniformData::Vec4(GROUND_LINE_COLOR.to_f32().0)),
                (&self.ground_program.gridline_count_uniform, UniformData::Int(GRIDLINE_COUNT)),
            ],
            viewport: self.renderer.draw_viewport(),
            options: RenderOptions {
                depth: Some(DepthState { func: DepthFunc::Less, write: true }),
                clear_ops: ClearOps { color: clear_color, depth: Some(1.0), stencil: Some(0) },
                ..RenderOptions::default()
            },
        });
    }
fn draw_environment ( & self , render_scene_index : u32 ) { let frame = & self . current_frame . as_ref ( ) . unwrap ( ) ; let perspective = match frame . transform { RenderTransform :: Transform2D ( .. ) => return , RenderTransform :: Perspective ( perspective ) => perspective , } ; if self . ui_model . background_color == BackgroundColor :: Transparent { return ; } let ground_scale = self . scene_metadata . view_box . max_x ( ) * 2.0 ; let mut offset = self . scene_metadata . view_box . lower_right ( ) . to_4d ( ) ; offset . set_z ( ground_scale ) ; offset = offset * Vector4F :: new ( - 0.5 , 1.0 , - 0.5 , 1.0 ) ; let base_transform = perspective . transform * Transform4F :: from_translation ( offset ) ; // Fill ground. let transform = base_transform * Transform4F :: from_scale ( Vector4F :: new ( ground_scale , 1.0 , ground_scale , 1.0 ) ) ; // Don't clear the first scene after drawing it. let clear_color = if render_scene_index == 0 { Some ( self . background_color ( ) . to_f32 ( ) ) } else { None } ; self . renderer . device . draw_elements ( 6 , & RenderState { target : & self . renderer . draw_render_target ( ) , program : & self . ground_program . program , vertex_array : & self . ground_vertex_array . vertex_array , primitive : Primitive :: Triangles , textures : & [ ] , uniforms : & [ ( & self . ground_program . transform_uniform , UniformData :: from_transform_3d ( & transform ) ) , ( & self . ground_program . ground_color_uniform , UniformData :: Vec4 ( GROUND_SOLID_COLOR . to_f32 ( ) . 0 ) ) , ( & self . ground_program . gridline_color_uniform , UniformData :: Vec4 ( GROUND_LINE_COLOR . to_f32 ( ) . 0 ) ) , ( & self . ground_program . gridline_count_uniform , UniformData :: Int ( GRIDLINE_COUNT ) ) , ] , viewport : self . renderer . draw_viewport ( ) , options : RenderOptions { depth : Some ( DepthState { func : DepthFunc :: Less , write : true } ) , clear_ops : ClearOps { color : clear_color , depth : Some ( 1.0 ) , stencil : Some ( 0 ) } , .. RenderOptions :: default ( ) } , } ) ; }
Draws the ground, if applicable.
Draws the ground if applicable .
&self
render_scene_index
u32