use super::ExampleScene; use crate::basic_scene::BasicScene; use ray_tracing_core::prelude::*; use std::cell::{Cell, OnceCell}; pub struct SphereScene { scene: OnceCell>, material: Cell>, } impl SphereScene { pub fn new(material: M) -> Self { Self { scene: OnceCell::new(), material: Cell::new(Some(material)), } } } impl + Clone + 'static> ExampleScene for SphereScene { fn get_scene(&self) -> Box + Sync> { let s = self .scene .get_or_init(|| BasicScene::new(self.material.take().unwrap())); Box::new(s.clone()) } fn get_camera_pos(&self) -> Pos3 { Pos3::new(5.0, 1.0, 0.0) } fn get_camera_look_at(&self) -> Pos3 { Pos3::new(0.0, 0.0, 0.0) } fn get_camera_up(&self) -> Dir3 { Dir3::up() } fn get_horizontal_fov(&self) -> Float { Float::to_radians(90.0) } }