diff options
Diffstat (limited to 'world')
-rw-r--r-- | world/src/main.rs | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/world/src/main.rs b/world/src/main.rs index 1b59cc6..c10f0b0 100644 --- a/world/src/main.rs +++ b/world/src/main.rs @@ -44,15 +44,24 @@ use weareshared::{ #[derive(Parser)] struct Args { address: SocketAddr, + /// Path to a glTF file, binary or json format scene: PathBuf, + /// Send all resources to the server then quit #[arg(short, long)] push: bool, + /// Spin the object #[arg(short, long)] spin: bool, + /// Remove all other object from the world #[arg(short, long)] clear: bool, + /// Add the object to the world + #[arg(short, long)] + add: bool, + /// Transcode all textures to WebP #[arg(short, long)] webp: bool, + /// Register to the prefab index #[arg(short, long)] name: Option<String>, } @@ -103,12 +112,23 @@ fn main() -> Result<()> { })?, )); - let ob = Object::new(); let pres = store.set(&prefab)?; - Packet::Add(ob, pres.clone()).write(&mut sock)?; - sock.flush()?; + + if let Some(name) = args.name { + Packet::PrefabName(pres.clone(), name).write(&mut sock)?; + sock.flush()?; + } + let ob = if args.add { + let ob = Object::new(); + Packet::Add(ob, pres.clone()).write(&mut sock)?; + sock.flush()?; + Some(ob) + } else { + None + }; if args.spin { + let ob = ob.clone().unwrap(); let mut sock2 = sock.try_clone().unwrap(); thread::spawn(move || { let mut x = 0.; @@ -123,11 +143,6 @@ fn main() -> Result<()> { }); } - if let Some(name) = args.name { - Packet::PrefabName(pres, name).write(&mut sock)?; - sock.flush()?; - } - if args.push { store.iter(|d| { Packet::RespondResource(Data(d.to_vec())) @@ -146,7 +161,7 @@ fn main() -> Result<()> { } } Packet::Add(ob_a, _) => { - if ob_a != ob { + if Some(ob_a) != ob { info!("removing object {ob_a}"); Packet::Remove(ob_a).write(&mut sock)?; sock.flush()?; |