diff options
author | metamuffin <metamuffin@disroot.org> | 2025-02-12 14:56:54 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-02-12 14:56:54 +0100 |
commit | 0c180e60c33934c8a9d9dc8060a22219d4b7901f (patch) | |
tree | 07027c9443c3c86bc5f50aeac735e6af1f98f35c | |
parent | ae9e813eaf5b04c8dddc9da1a1f5d50da1f5bddb (diff) | |
download | weareserver-0c180e60c33934c8a9d9dc8060a22219d4b7901f.tar weareserver-0c180e60c33934c8a9d9dc8060a22219d4b7901f.tar.bz2 weareserver-0c180e60c33934c8a9d9dc8060a22219d4b7901f.tar.zst |
default sun option
-rw-r--r-- | doc/resources.md | 2 | ||||
-rw-r--r-- | world/src/main.rs | 38 |
2 files changed, 33 insertions, 7 deletions
diff --git a/doc/resources.md b/doc/resources.md index 7ef22be..a382858 100644 --- a/doc/resources.md +++ b/doc/resources.md @@ -147,6 +147,8 @@ inherited. Attribute values are zipped similar to vertex attributes. - **Skybox**: Equirectangular projection is used. TODO: Unit for Luminous intensity? lm/sr? +- **Sun**: Direction is a normal vector, color is illuminance of each channel in + lux. ## Texture diff --git a/world/src/main.rs b/world/src/main.rs index 00a5913..08a89cc 100644 --- a/world/src/main.rs +++ b/world/src/main.rs @@ -86,6 +86,9 @@ pub struct Args { #[arg(long)] use_cache: bool, + #[arg(short = 'S', long)] + with_default_sun: bool, + /// Spins the object #[arg(long)] debug_spin: bool, @@ -124,6 +127,11 @@ fn main() -> Result<()> { let root = gltf.default_scene().ok_or(anyhow!("no default scene"))?; + eprintln!("{:?}", gltf.extensions_used()); + eprintln!("{:?}", gltf.extensions()); + eprintln!("{:?}", root.extensions()); + eprintln!("{:?}", root.extras()); + let mut nodes = Vec::new(); fn traverse<'a>(out: &mut Vec<(Affine3A, Node<'a>)>, node: Node<'a>, trans: Affine3A) { let trans = trans * transform_to_affine(node.transform()); @@ -216,7 +224,11 @@ fn main() -> Result<()> { .par_iter() .map(|(trans, node)| { let mut prefab = Prefab::default(); - + if node.name().unwrap_or_default() == "particles" { + eprintln!("{:?}", node.transform()); + eprintln!("{:?}", node.extensions()); + eprintln!("{:?}", node.extras()); + } if !node.name().unwrap_or_default().ends_with("-collider") { if let Some(mesh) = node.mesh() { import_mesh( @@ -279,14 +291,26 @@ fn main() -> Result<()> { vec![] }; - if let Some(skybox) = &args.skybox { + let skybox = if let Some(skybox) = &args.skybox { let mut buf = Vec::new(); File::open(skybox)?.read_to_end(&mut buf)?; - prefab.environment = Some(store.set(&EnvironmentPart { - skybox: Some(store.set(&Image(Cow::Owned(buf)))?), - ..Default::default() - })?); - } + Some(store.set(&Image(Cow::Owned(buf)))?) + } else { + None + }; + let sun = if args.with_default_sun { + Some(( + vec3a(1., -5., 1.).normalize(), + vec3a(100_000., 100_000., 100_000.), + )) + } else { + None + }; + prefab.environment = if skybox.is_some() || sun.is_some() { + Some(store.set(&EnvironmentPart { skybox, sun })?) + } else { + None + }; prefab.name = args.name.clone().or(gltf .default_scene() |