diff options
Diffstat (limited to 'world/src/main.rs')
-rw-r--r-- | world/src/main.rs | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/world/src/main.rs b/world/src/main.rs index 055be47..e3c365a 100644 --- a/world/src/main.rs +++ b/world/src/main.rs @@ -42,7 +42,7 @@ use std::{ thread::{self, sleep}, time::Duration, }; -use vrm::{Vrm, Vrmc}; +use vrm::extract_vrm_data; use weareshared::{ Affine3A, Vec3A, helper::ReadWrite, @@ -137,6 +137,8 @@ fn main() -> Result<()> { traverse(&mut nodes, node, root_affine); } + let vrm = extract_vrm_data(&gltf)?; + let mut skin_index_to_arm_index = BTreeMap::new(); let armature = { let mut joint_index_to_arm_index = BTreeMap::new(); @@ -176,19 +178,9 @@ fn main() -> Result<()> { }) .collect::<Vec<_>>(); - if let Some(vrm) = gltf.extension_value("VRM") { - let vrm: Vrm = serde_json::from_value(vrm.clone())?; - for bone in vrm.humanoid.human_bones { - let ind = joint_index_to_arm_index[&bone.node]; - name[ind] = bone.bone; - } - } - if let Some(vrm) = gltf.extension_value("VRMC_vrm") { - let vrm: Vrmc = serde_json::from_value(vrm.clone())?; - for (bname, bone) in vrm.humanoid.human_bones { - let ind = joint_index_to_arm_index[&bone.node]; - name[ind] = bname; - } + for (node, bname) in &vrm.bone_node_names { + let ind = joint_index_to_arm_index[node]; + name[ind] = bname.to_owned(); } for (i, (name, tr)) in name.iter().zip(transform.iter()).enumerate() { @@ -226,6 +218,7 @@ fn main() -> Result<()> { &args, &texture_cache, &skin_index_to_arm_index, + &vrm, )?; } } |