Make standard planes available from Surfaces

This commit is contained in:
Hanno Braun 2022-10-11 13:06:20 +02:00
parent c1972f618c
commit 9a6b7f7d05

View File

@ -128,9 +128,13 @@ impl Objects {
}
/// The store for [`Surface`]s
#[derive(Debug, Default)]
#[derive(Debug)]
pub struct Surfaces {
store: Store<Surface>,
xy_plane: Handle<Surface>,
xz_plane: Handle<Surface>,
yz_plane: Handle<Surface>,
}
impl Surfaces {
@ -138,4 +142,36 @@ impl Surfaces {
pub fn insert(&self, surface: Surface) -> Handle<Surface> {
self.store.insert(surface)
}
/// Access the xy-plane
pub fn xy_plane(&self) -> Handle<Surface> {
self.xy_plane.clone()
}
/// Access the xz-plane
pub fn xz_plane(&self) -> Handle<Surface> {
self.xz_plane.clone()
}
/// Access the yz-plane
pub fn yz_plane(&self) -> Handle<Surface> {
self.yz_plane.clone()
}
}
impl Default for Surfaces {
fn default() -> Self {
let store = Store::new();
let xy_plane = store.insert(Surface::xy_plane());
let xz_plane = store.insert(Surface::xz_plane());
let yz_plane = store.insert(Surface::yz_plane());
Self {
store,
xy_plane,
xz_plane,
yz_plane,
}
}
}