bevy/examples/3d
François c6958b3056 add a SceneBundle to spawn a scene (#2424)
# Objective

- Spawning a scene is handled as a special case with a command `spawn_scene` that takes an handle but doesn't let you specify anything else. This is the only handle that works that way.
- Workaround for this have been to add the `spawn_scene` on `ChildBuilder` to be able to specify transform of parent, or to make the `SceneSpawner` available to be able to select entities from a scene by their instance id

## Solution

Add a bundle
```rust
pub struct SceneBundle {
    pub scene: Handle<Scene>,
    pub transform: Transform,
    pub global_transform: GlobalTransform,
    pub instance_id: Option<InstanceId>,
}
```

and instead of 
```rust
commands.spawn_scene(asset_server.load("models/FlightHelmet/FlightHelmet.gltf#Scene0"));
```
you can do
```rust
commands.spawn_bundle(SceneBundle {
    scene: asset_server.load("models/FlightHelmet/FlightHelmet.gltf#Scene0"),
    ..Default::default()
});
```

The scene will be spawned as a child of the entity with the `SceneBundle`

~I would like to remove the command `spawn_scene` in favor of this bundle but didn't do it yet to get feedback first~

Co-authored-by: François <8672791+mockersf@users.noreply.github.com>
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2022-06-09 20:34:09 +00:00
..
3d_scene.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
lighting.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
load_gltf.rs add a SceneBundle to spawn a scene (#2424) 2022-06-09 20:34:09 +00:00
msaa.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
orthographic.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
parenting.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
pbr.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
render_to_texture.rs Add "depth_load_op" configuration to 3d Cameras (#4904) 2022-06-07 22:22:10 +00:00
shadow_biases.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
shadow_caster_receiver.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
shapes.rs use the default() method in examples instead of Default::default() (#4952) 2022-06-07 02:16:47 +00:00
spherical_area_lights.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
split_screen.rs add a SceneBundle to spawn a scene (#2424) 2022-06-09 20:34:09 +00:00
texture.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
transparency_3d.rs use the default() method in examples instead of Default::default() (#4952) 2022-06-07 02:16:47 +00:00
two_passes.rs Add "depth_load_op" configuration to 3d Cameras (#4904) 2022-06-07 22:22:10 +00:00
update_gltf_scene.rs add a SceneBundle to spawn a scene (#2424) 2022-06-09 20:34:09 +00:00
vertex_colors.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
wireframe.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00