summaryrefslogtreecommitdiff
path: root/world/src/main.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-01-06 15:34:40 +0100
committermetamuffin <metamuffin@disroot.org>2025-01-06 15:34:40 +0100
commit14d348febd549b944d03030bf748f7817a2bedac (patch)
tree96fb79928296a9b6e6b50e0c805fcafaaf32e16a /world/src/main.rs
parent48a0fb31737362c9bae0ff8f6fcf1e4e10600f94 (diff)
downloadweareserver-14d348febd549b944d03030bf748f7817a2bedac.tar
weareserver-14d348febd549b944d03030bf748f7817a2bedac.tar.bz2
weareserver-14d348febd549b944d03030bf748f7817a2bedac.tar.zst
a
Diffstat (limited to 'world/src/main.rs')
-rw-r--r--world/src/main.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/world/src/main.rs b/world/src/main.rs
index 772c87d..fe71e79 100644
--- a/world/src/main.rs
+++ b/world/src/main.rs
@@ -6,8 +6,9 @@ use std::{
path::PathBuf,
};
use weareshared::{
+ Affine3A, Mat3A, Vec3A,
packets::{Object, Packet, ReadWrite},
- resources::{Attribute, AttributeArray, IndexArray, Part},
+ resources::{Attribute, AttributeArray, IndexArray, Part, Prefab},
store::ResourceStore,
};
@@ -26,6 +27,7 @@ fn main() -> Result<()> {
let (gltf, buffers, _) = gltf::import(args.scene)?;
+ let mut prefab = Prefab::default();
for node in gltf.nodes() {
if let Some(mesh) = node.mesh() {
for p in mesh.primitives() {
@@ -71,11 +73,21 @@ fn main() -> Result<()> {
}
.write_alloc(),
)?;
- Packet::Add(Object::new(), part).write(&mut sock)?;
+
+ let mat = node.transform().matrix();
+ let aff = Affine3A::from_cols_array_2d(&[
+ [mat[0][0], mat[0][1], mat[0][2]],
+ [mat[1][0], mat[1][1], mat[1][2]],
+ [mat[2][0], mat[2][1], mat[2][2]],
+ [mat[3][0], mat[3][1], mat[3][2]],
+ ]);
+ prefab.0.push((aff, part))
}
}
}
+ Packet::Add(Object::new(), store.set(&prefab.write_alloc())?).write(&mut sock)?;
+
store.iter(|d| {
Packet::RespondResource(d.to_vec())
.write(&mut sock)