lyra-wasm-scripting-test/common-api/src/math.rs

40 lines
673 B
Rust
Raw Normal View History

use api_derive::bytemuck_component_impl;
use crate as common_api;
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable)]
pub struct Vec3 {
x: f32,
y: f32,
z: f32,
}
impl Vec3 {
pub fn new(x: f32, y: f32, z: f32) -> Self {
Self {
x, y, z
}
}
}
bytemuck_component_impl!(Vec3);
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable)]
pub struct Vec4 {
x: f32,
y: f32,
z: f32,
w: f32,
}
impl Vec4 {
pub fn new(x: f32, y: f32, z: f32, w: f32) -> Self {
Self {
x, y, z, w
}
}
}
bytemuck_component_impl!(Vec4);