Some gltf improvements #4

Merged
SeanOMik merged 13 commits from feature/gltf-scene-fixes into main 2024-03-09 05:46:45 +00:00
1 changed files with 14 additions and 3 deletions
Showing only changes of commit 05ad91a64f - Show all commits

View File

@ -162,6 +162,13 @@ impl<'a> SceneGraph<'a> {
world_add_child_node(&mut self.world, parent, local_transform, bundle) world_add_child_node(&mut self.world, parent, local_transform, bundle)
} }
pub fn add_empty_node_under(&mut self, parent: &SceneNode, local_transform: Transform) -> SceneNode {
let e = self.world.spawn((SceneNodeFlag, local_transform));
self.world.add_relation(e, ChildOf, parent.entity());
SceneNode::new(Some(parent.entity()), e)
}
/// Traverses down the SceneGraph, calling `callback` with each SceneNode and its world transform. /// Traverses down the SceneGraph, calling `callback` with each SceneNode and its world transform.
/// ///
/// The traversal does not include the root scene node. /// The traversal does not include the root scene node.
@ -189,6 +196,10 @@ impl<'a> SceneGraph<'a> {
self.traverse_down_from(node, callback); self.traverse_down_from(node, callback);
} }
} }
pub fn root_node(&self) -> SceneNode {
self.root_node.clone()
}
} }
/// Add a node under a parent node. /// Add a node under a parent node.
@ -256,7 +267,7 @@ pub mod tests {
}); });
} }
#[test] /* #[test]
fn inserting_and_from_world() { fn inserting_and_from_world() {
let v2s = vec![Vec3::new(10.0, 10.0, 10.0), Vec3::new(50.0, 50.0, 50.0)]; let v2s = vec![Vec3::new(10.0, 10.0, 10.0), Vec3::new(50.0, 50.0, 50.0)];
@ -301,5 +312,5 @@ pub mod tests {
idx += 1; idx += 1;
}); });
} } */
} }