Skip to main content

rscad_core/objects/three_dimensional/
sphere.rs

1use crate::prelude_::*;
2
3#[derive(Clone, Copy, Debug, Default)]
4#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5#[cfg_attr(feature = "reflect", derive(bevy_reflect::Reflect))]
6pub struct Sphere {
7    pub radius: f64,
8    pub stacks: usize,
9    pub fn_: usize,
10}
11
12impl Sphere {
13    pub fn new<R: Number>(
14        radius: R,
15        fn_: impl Into<Option<usize>>,
16        stacks: impl Into<Option<usize>>,
17    ) -> Self {
18        Self {
19            radius: radius.to_f64(),
20            fn_: fn_.into().unwrap_or(32),
21            stacks: stacks.into().unwrap_or(16),
22        }
23    }
24}
25
26impl Object for Sphere {}