glorbs/src/util/vector3_i32.rs

37 lines
907 B
Rust

use bevy::prelude::*;
use super::Vector3;
pub type Vector3I = Vector3<i32>;
impl Vector3I {
pub const ZERO: Self = Self { x: 0, y: 0, z: 0 };
pub const ONE: Self = Self { x: 1, y: 1, z: 1 };
pub const UP: Self = Self { x: 0, y: 1, z: 0 };
pub const DOWN: Self = Self { x: 0, y: -1, z: 0 };
pub const LEFT: Self = Self { x: -1, y: 0, z: 0 };
pub const RIGHT: Self = Self { x: 1, y: 0, z: 0 };
pub const FORWARD: Self = Self { x: 0, y: 0, z: -1 };
pub const BACK: Self = Self { x: 0, y: 0, z: 1 };
}
impl From<Vec3> for Vector3I {
fn from(vec: Vec3) -> Self {
Self {
x: vec.x as i32,
y: vec.y as i32,
z: vec.y as i32,
}
}
}
impl From<Vector3I> for Vec3 {
fn from(vec: Vector3I) -> Self {
Vec3 {
x: vec.x as f32,
y: vec.y as f32,
z: vec.z as f32,
}
}
}