@@ -6,10 +6,10 @@ use bevy::{
66 AssetPath , LoadState , handle_internal_asset_events,
77 io:: { AssetSourceId , embedded:: GetAssetServer } ,
88 } ,
9+ camera:: visibility:: RenderLayers ,
910 ecs:: system:: RunSystemOnce ,
1011 gltf:: { Gltf , GltfMeshName } ,
1112 prelude:: * ,
12- camera:: visibility:: RenderLayers ,
1313 scene:: SceneSpawner ,
1414} ;
1515
@@ -52,10 +52,7 @@ fn block_on_load(world: &mut World, load_state: impl Fn(&World) -> LoadState) ->
5252}
5353
5454fn compute_global_transform ( world : & World , entity : Entity ) -> Transform {
55- let local = world
56- . get :: < Transform > ( entity)
57- . copied ( )
58- . unwrap_or_default ( ) ;
55+ let local = world. get :: < Transform > ( entity) . copied ( ) . unwrap_or_default ( ) ;
5956 match world. get :: < ChildOf > ( entity) {
6057 Some ( child_of) => {
6158 let parent_global = compute_global_transform ( world, child_of. parent ( ) ) ;
@@ -99,14 +96,12 @@ pub fn load(
9996
10097 // we spawn the scene in to the world in a blocking fashion so that bevy runs all
10198 // its hooks for the gltf, ex creating standard material instances
102- let instance_id =
103- world. resource_scope ( |world, mut spawner : Mut < SceneSpawner > | {
104- spawner
105- . spawn_sync ( world, & scene_handle)
106- . map_err ( |e| ProcessingError :: GltfLoadError ( format ! ( "Scene spawn failed: {e}" ) ) )
107- } ) ?;
99+ let instance_id = world. resource_scope ( |world, mut spawner : Mut < SceneSpawner > | {
100+ spawner
101+ . spawn_sync ( world, & scene_handle)
102+ . map_err ( |e| ProcessingError :: GltfLoadError ( format ! ( "Scene spawn failed: {e}" ) ) )
103+ } ) ?;
108104
109-
110105 // we have to remove the existing cameras from the scene -- the user can request to set *this*
111106 // graphics to a camera, but the scenes cameras should not exist
112107 {
@@ -144,7 +139,7 @@ pub fn geometry(
144139
145140 let ( mesh_handle, global_transform) = {
146141 let spawner = world. resource :: < SceneSpawner > ( ) ;
147-
142+
148143 // find the mesh with the given name component that bevy added post-spawn
149144 // name is derived from gltf node or computed
150145 let mesh_entity = spawner
@@ -248,17 +243,10 @@ pub fn material_names(In(gltf_entity): In<Entity>, world: &mut World) -> Result<
248243 let gltf = gltf_assets
249244 . get ( & gltf_handle)
250245 . ok_or_else ( || ProcessingError :: GltfLoadError ( "GLTF asset not found" . into ( ) ) ) ?;
251- Ok ( gltf
252- . named_materials
253- . keys ( )
254- . map ( |k| k. to_string ( ) )
255- . collect ( ) )
246+ Ok ( gltf. named_materials . keys ( ) . map ( |k| k. to_string ( ) ) . collect ( ) )
256247}
257248
258- pub fn camera (
259- In ( ( gltf_entity, index) ) : In < ( Entity , usize ) > ,
260- world : & mut World ,
261- ) -> Result < ( ) > {
249+ pub fn camera ( In ( ( gltf_entity, index) ) : In < ( Entity , usize ) > , world : & mut World ) -> Result < ( ) > {
262250 let gltf_handle = world
263251 . get :: < GltfHandle > ( gltf_entity)
264252 . ok_or ( ProcessingError :: InvalidEntity ) ?;
@@ -324,10 +312,7 @@ pub fn camera(
324312 Ok ( ( ) )
325313}
326314
327- pub fn light (
328- In ( ( gltf_entity, index) ) : In < ( Entity , usize ) > ,
329- world : & mut World ,
330- ) -> Result < Entity > {
315+ pub fn light ( In ( ( gltf_entity, index) ) : In < ( Entity , usize ) > , world : & mut World ) -> Result < Entity > {
331316 let gltf_handle = world
332317 . get :: < GltfHandle > ( gltf_entity)
333318 . ok_or ( ProcessingError :: InvalidEntity ) ?;
0 commit comments