summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/src/data_types/vector.rs44
1 files changed, 35 insertions, 9 deletions
diff --git a/engine/src/data_types/vector.rs b/engine/src/data_types/vector.rs
index 1a4e49e..adbdfff 100644
--- a/engine/src/data_types/vector.rs
+++ b/engine/src/data_types/vector.rs
@@ -103,6 +103,22 @@ where
}
}
+impl<Value> From<[Value; 2]> for Vec2<Value>
+{
+ fn from([x, y]: [Value; 2]) -> Self
+ {
+ Self { x, y }
+ }
+}
+
+impl<Value> From<Vec2<Value>> for [Value; 2]
+{
+ fn from(vec: Vec2<Value>) -> Self
+ {
+ [vec.x, vec.y]
+ }
+}
+
impl<Value> VecN<Value, 2> for Vec2<Value>
{
fn into_array(self) -> [Value; 2]
@@ -356,17 +372,11 @@ where
}
}
-impl<Value> From<Value> for Vec3<Value>
-where
- Value: Clone,
+impl From<f32> for Vec3<f32>
{
- fn from(value: Value) -> Self
+ fn from(value: f32) -> Self
{
- Self {
- x: value.clone(),
- y: value.clone(),
- z: value,
- }
+ Self { x: value, y: value, z: value }
}
}
@@ -382,6 +392,22 @@ impl<Value> From<Color<Value>> for Vec3<Value>
}
}
+impl<Value> From<[Value; 3]> for Vec3<Value>
+{
+ fn from([x, y, z]: [Value; 3]) -> Self
+ {
+ Self { x, y, z }
+ }
+}
+
+impl<Value> From<Vec3<Value>> for [Value; 3]
+{
+ fn from(vec: Vec3<Value>) -> Self
+ {
+ [vec.x, vec.y, vec.z]
+ }
+}
+
impl<Value> VecN<Value, 3> for Vec3<Value>
{
fn into_array(self) -> [Value; 3]