world: add default empty World constructor.

This commit is contained in:
Bill Thiede 2021-07-17 15:07:14 -07:00
parent cbecaa70ef
commit 3bc9f6f924
3 changed files with 21 additions and 0 deletions

View File

@ -6,6 +6,7 @@ pub mod matrices;
pub mod rays;
pub mod spheres;
pub mod tuples;
pub mod world;
/// Value considered close enough for PartialEq implementations.
pub const EPSILON: f32 = 0.00001;

View File

@ -1,5 +1,6 @@
use crate::tuples::{Color, Tuple};
#[derive(Debug, PartialEq)]
pub struct PointLight {
pub position: Tuple,
pub intensity: Color,

19
rtchallenge/src/world.rs Normal file
View File

@ -0,0 +1,19 @@
use crate::{lights::PointLight, spheres::Sphere};
/// World holds all drawable objects and the light(s) that illuminate them.
///
/// # Examples
/// ```
/// use rtchallenge::world::World;
///
/// let w = World::default();
/// assert!(w.objects.is_empty());
/// assert_eq!(w.light, None);
/// ```
#[derive(Debug, Default)]
pub struct World {
// TODO(wathiede): make this a list of abstract Light traits.
pub light: Option<PointLight>,
pub objects: Vec<Sphere>,
}