refactor: rename a few things

This commit is contained in:
2025-02-17 11:53:24 -05:00
parent 93348835ac
commit 2373d6500e
21 changed files with 7 additions and 7 deletions

36
src/lua/vec3.rs Normal file
View File

@@ -0,0 +1,36 @@
use mlua::{FromLua, IntoLua, Lua, Result, Value};
#[derive(Clone)]
pub struct Vec3 {
pub x: f64,
pub y: f64,
pub z: f64,
}
impl IntoLua for Vec3 {
fn into_lua(self, lua: &Lua) -> Result<Value> {
let table = lua.create_table()?;
table.set("x", self.x)?;
table.set("y", self.y)?;
table.set("z", self.z)?;
Ok(Value::Table(table))
}
}
impl FromLua for Vec3 {
fn from_lua(value: Value, _lua: &Lua) -> Result<Self> {
if let Value::Table(table) = value {
Ok(Self {
x: table.get("x")?,
y: table.get("y")?,
z: table.get("z")?,
})
} else {
Err(mlua::Error::FromLuaConversionError {
from: value.type_name(),
to: "Position".to_string(),
message: None,
})
}
}
}