Struct gemini_engine::elements3d::view3d::vec3d::Vec3D
source · pub struct Vec3D {
pub x: f64,
pub y: f64,
pub z: f64,
}Fields§
§x: f64§y: f64§z: f64Implementations§
source§impl Vec3D
impl Vec3D
pub const ZERO: Self = _
pub const ONE: Self = _
sourcepub const fn new(x: f64, y: f64, z: f64) -> Self
pub const fn new(x: f64, y: f64, z: f64) -> Self
Examples found in repository?
examples/spinning-cube.rs (line 16)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
fn main() {
let mut frame_skip = false;
let mut view = View::new(350, 90, ColChar::BACKGROUND);
let mut viewport = Viewport::new(
Transform3D::new_tr(Vec3D::new(0.0, 0.0, 5.0), Vec3D::new(-0.5, 0.3, 0.0)),
FOV,
Vec2D::new((view.width / 2) as isize, (view.height / 2) as isize),
);
let cube = Mesh3D::default_cube();
loop {
let now = gameloop::Instant::now();
view.clear();
viewport.transform.rotation.y -= 0.05;
match frame_skip {
true => frame_skip = false,
false => {
view.blit(
&viewport.render(vec![&cube], DisplayMode::Solid),
Wrapping::Ignore,
);
view.display_render().unwrap();
}
}
let elapsed = now.elapsed();
println!(
"Elapsed: {:.2?}µs | Frame skip: {}",
elapsed.as_micros(),
frame_skip
);
frame_skip = gameloop::sleep_fps(FPS, Some(elapsed));
}
}pub fn as_tuple(&self) -> (f64, f64, f64)
pub fn dot(&self, other: Vec3D) -> f64
pub fn magnitude(&self) -> f64
Trait Implementations§
source§impl AddAssign<Vec3D> for Vec3D
impl AddAssign<Vec3D> for Vec3D
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moresource§impl DivAssign<f64> for Vec3D
impl DivAssign<f64> for Vec3D
source§fn div_assign(&mut self, rhs: f64)
fn div_assign(&mut self, rhs: f64)
Performs the
/= operation. Read moresource§impl Mul<Vec3D> for Transform3D
impl Mul<Vec3D> for Transform3D
source§impl MulAssign<Vec3D> for Vec3D
impl MulAssign<Vec3D> for Vec3D
source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*= operation. Read moresource§impl MulAssign<f64> for Vec3D
impl MulAssign<f64> for Vec3D
source§fn mul_assign(&mut self, rhs: f64)
fn mul_assign(&mut self, rhs: f64)
Performs the
*= operation. Read moresource§impl PartialEq<Vec3D> for Vec3D
impl PartialEq<Vec3D> for Vec3D
source§impl RemAssign<Vec3D> for Vec3D
impl RemAssign<Vec3D> for Vec3D
source§fn rem_assign(&mut self, rhs: Vec3D)
fn rem_assign(&mut self, rhs: Vec3D)
Performs the
%= operation. Read moresource§impl SubAssign<Vec3D> for Vec3D
impl SubAssign<Vec3D> for Vec3D
source§fn sub_assign(&mut self, rhs: Vec3D)
fn sub_assign(&mut self, rhs: Vec3D)
Performs the
-= operation. Read moreimpl Copy for Vec3D
Auto Trait Implementations§
impl RefUnwindSafe for Vec3D
impl Send for Vec3D
impl Sync for Vec3D
impl Unpin for Vec3D
impl UnwindSafe for Vec3D
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more