blob: c6e3a0da7ffc987fff4a137b63fd3b1409e35051 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
use super::FromValue;
use crate::object::Value;
use glam::{Quat, Vec3};
impl FromValue for Vec3 {
fn from_value(v: Value) -> anyhow::Result<Self> {
let fields = v.as_class("Vector3f").unwrap();
Ok(Self {
x: fields["x"].as_f32().unwrap(),
y: fields["y"].as_f32().unwrap(),
z: fields["z"].as_f32().unwrap(),
})
}
}
impl FromValue for Quat {
fn from_value(v: Value) -> anyhow::Result<Self> {
let fields = v.as_class("Quaternionf").unwrap();
Ok(Self::from_array([
fields["x"].as_f32().unwrap(),
fields["y"].as_f32().unwrap(),
fields["z"].as_f32().unwrap(),
fields["w"].as_f32().unwrap(),
]))
}
}
|