shapes:: helpers for creating Shapes added to the prelude.
This commit is contained in:
parent
0965ac9ddf
commit
4680c97adc
@ -40,7 +40,10 @@ pub use float::Float;
|
||||
|
||||
pub mod prelude {
|
||||
pub use crate::{
|
||||
materials::{Material, MaterialBuilder},
|
||||
matrices::{identity, rotation_x, rotation_y, rotation_z, scaling, shearing, translation},
|
||||
shapes::{plane, sphere, test_shape},
|
||||
transformations::view_transform,
|
||||
tuples::{point, vector, Color},
|
||||
};
|
||||
}
|
||||
|
||||
@ -53,6 +53,40 @@ pub struct Shape {
|
||||
geometry: Geometry,
|
||||
}
|
||||
|
||||
/// Short hand for creating a Shape with a plane geometry.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```
|
||||
/// use rtchallenge::shapes::{plane, Shape};
|
||||
///
|
||||
/// assert_eq!(plane(), Shape::plane());
|
||||
/// ```
|
||||
pub fn plane() -> Shape {
|
||||
Shape::plane()
|
||||
}
|
||||
/// Short hand for creating a Shape with a sphere geometry.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```
|
||||
/// use rtchallenge::shapes::{sphere, Shape};
|
||||
///
|
||||
/// assert_eq!(sphere(), Shape::sphere());
|
||||
/// ```
|
||||
pub fn sphere() -> Shape {
|
||||
Shape::sphere()
|
||||
}
|
||||
/// Short hand for creating a Shape with a test shape geometry.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```
|
||||
/// use rtchallenge::shapes::{test_shape, Shape};
|
||||
///
|
||||
/// assert_eq!(test_shape(), Shape::test_shape());
|
||||
/// ```
|
||||
pub fn test_shape() -> Shape {
|
||||
Shape::test_shape()
|
||||
}
|
||||
|
||||
impl ShapeBuilder {
|
||||
fn default_inverse_transform(&self) -> Result<Matrix4x4, String> {
|
||||
Ok(self.transform.unwrap_or(Matrix4x4::identity()).inverse())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user