summaryrefslogtreecommitdiff
path: root/world
diff options
context:
space:
mode:
Diffstat (limited to 'world')
-rw-r--r--world/src/main.rs15
-rw-r--r--world/src/mesh.rs12
2 files changed, 25 insertions, 2 deletions
diff --git a/world/src/main.rs b/world/src/main.rs
index 7f531b4..af32222 100644
--- a/world/src/main.rs
+++ b/world/src/main.rs
@@ -19,7 +19,7 @@ pub mod mesh;
use anyhow::{Result, bail};
use clap::Parser;
-use gltf::image::Source;
+use gltf::{Gltf, image::Source, import_buffers};
use image::{ImageReader, codecs::webp::WebPEncoder};
use log::info;
use mesh::import_mesh;
@@ -78,10 +78,21 @@ fn main() -> Result<()> {
Packet::Connect(random()).write(&mut sock)?;
- let (gltf, buffers, _) = gltf::import(&args.scene)?;
+ // let (gltf, buffers, _) = gltf::import(&args.scene)?;
let path_base = args.scene.parent().unwrap();
+ let gltf = Gltf::from_reader_without_validation(File::open(&args.scene)?)?;
+
+ let buffers = import_buffers(&gltf, Some(path_base), None)?;
+
let mut prefab = Prefab::default();
+
+ prefab.name = gltf
+ .default_scene()
+ .map(|n| n.name())
+ .flatten()
+ .map(|n| n.to_owned());
+
for node in gltf.nodes() {
if let Some(mesh) = node.mesh() {
import_mesh(
diff --git a/world/src/mesh.rs b/world/src/mesh.rs
index 2c868ab..1f19c28 100644
--- a/world/src/mesh.rs
+++ b/world/src/mesh.rs
@@ -308,6 +308,17 @@ pub fn import_mesh(
info!("name is {name:?}");
}
+ let g_unlit = if p
+ .material()
+ .extensions()
+ .map(|e| e.contains_key("KHR_materials_unlit"))
+ .unwrap_or(false)
+ {
+ Some(())
+ } else {
+ None
+ };
+
let mesh = store.set(&MeshPart {
name,
index,
@@ -321,6 +332,7 @@ pub fn import_mesh(
g_thickness,
g_refractive_index,
g_dispersion,
+ g_unlit,
va_position,
va_normal,
va_texcoord,