1
1
use anyhow:: Result ;
2
- use bevy_animation:: AnimationPlayer ;
3
2
use bevy_asset:: {
4
3
AssetIoError , AssetLoader , AssetPath , BoxedFuture , Handle , LoadContext , LoadedAsset ,
5
4
} ;
@@ -375,7 +374,7 @@ async fn load_gltf<'a, 'b>(
375
374
. insert_bundle ( SpatialBundle :: VISIBLE_IDENTITY )
376
375
. with_children ( |parent| {
377
376
for node in scene. nodes ( ) {
378
- match load_node (
377
+ let result = load_node (
379
378
& node,
380
379
parent,
381
380
load_context,
@@ -384,12 +383,10 @@ async fn load_gltf<'a, 'b>(
384
383
& mut entity_to_skin_index_map,
385
384
& mut active_camera_found,
386
385
Some ( & gltf) ,
387
- ) {
388
- Err ( e) => {
389
- err = Some ( Err ( e) as Result < ( ) , _ > ) ;
390
- return ;
391
- }
392
- Ok ( e) => ( ) ,
386
+ ) ;
387
+ if result. is_err ( ) {
388
+ err = Some ( result) ;
389
+ return ;
393
390
}
394
391
}
395
392
} ) ;
@@ -433,7 +430,7 @@ async fn load_gltf<'a, 'b>(
433
430
// };
434
431
435
432
#[ cfg( feature = "bevy_animation" ) ]
436
- let ( animations, named_animations, animation_roots ) = {
433
+ let ( animations, named_animations) = {
437
434
let mut animations = vec ! [ ] ;
438
435
let mut named_animations = HashMap :: default ( ) ;
439
436
for animation in gltf. animations ( ) {
@@ -504,22 +501,9 @@ async fn load_gltf<'a, 'b>(
504
501
}
505
502
animations. push ( handle) ;
506
503
}
507
- ( animations, named_animations, ( ) )
504
+ ( animations, named_animations)
508
505
} ;
509
506
510
- // #[cfg(feature = "bevy_animation")]
511
- // {
512
- // // for each node root in a scene, check if it's the root of an animation
513
- // // if it is, add the AnimationPlayer component
514
- // for node in gltf.scenes().flat_map(|s| s.nodes()) {
515
- // if animation_roots.contains(&node.index()) {
516
- // world
517
- // .entity_mut(*node_index_to_entity_map.get(&node.index()).unwrap())
518
- // .insert(bevy_animation::AnimationPlayer::default());
519
- // }
520
- // }
521
- // }
522
-
523
507
load_context. set_default_asset ( LoadedAsset :: new ( Gltf {
524
508
default_scene : gltf
525
509
. default_scene ( )
@@ -557,20 +541,20 @@ fn node_name(node: &Node) -> Name {
557
541
Name :: new ( name)
558
542
}
559
543
560
- #[ cfg( feature = "bevy_animation" ) ]
561
- fn paths_recur (
562
- node : Node ,
563
- current_path : & [ Name ] ,
564
- paths : & mut HashMap < usize , ( usize , Vec < Name > ) > ,
565
- root_index : usize ,
566
- ) {
567
- let mut path = current_path. to_owned ( ) ;
568
- path. push ( node_name ( & node) ) ;
569
- for child in node. children ( ) {
570
- paths_recur ( child, & path, paths, root_index) ;
571
- }
572
- paths. insert ( node. index ( ) , ( root_index, path) ) ;
573
- }
544
+ // #[cfg(feature = "bevy_animation")]
545
+ // fn paths_recur(
546
+ // node: Node,
547
+ // current_path: &[Name],
548
+ // paths: &mut HashMap<usize, (usize, Vec<Name>)>,
549
+ // root_index: usize,
550
+ // ) {
551
+ // let mut path = current_path.to_owned();
552
+ // path.push(node_name(&node));
553
+ // for child in node.children() {
554
+ // paths_recur(child, &path, paths, root_index);
555
+ // }
556
+ // paths.insert(node.index(), (root_index, path));
557
+ // }
574
558
575
559
/// Loads a glTF texture as a bevy [`Image`] and returns it together with its label.
576
560
async fn load_texture < ' a > (
0 commit comments