Skip to content

Commit 535cf40

Browse files
authored
Reframe old "scene" terminology as "world serialization" (#23630)
Part 2 of #23619 In **Bevy 0.19** we are landing a subset of Bevy's Next Generation Scene system (often known as BSN), which now lives in the `bevy_scene` / `bevy::scene` crate. However the old `bevy_scene` system still needs to stick around for a bit longer, as it provides some features that Bevy's Next Generation Scene system doesn't (yet!): 1. It is not _yet_ possible to write a World _to_ BSN, so the old system is still necessary for "round trip World serialization". 2. The GLTF scene loader has not yet been ported to BSN, so the old system is still necessary to spawn GLTF scenes in Bevy. For this reason, we have renamed the old `bevy_scene` crate to `bevy_world_serialization`. If you were referencing `bevy_scene::*` or `bevy::scene::*` types, rename those paths to `bevy_world_serialization::*` and `bevy::world_serialization::*` respectively. Additionally, to avoid confusion / conflicts with the new scene system, all "scene" terminology / types have been reframed as "world serialization": - `Scene` -> `WorldAsset` (as this was always just a World wrapper) - `SceneRoot` -> `WorldAssetRoot` - `DynamicScene` -> `DynamicWorld` - `DynamicScene::from_scene` -> `DynamicWorld::from_world_asset` - `DynamicSceneBuilder` -> `DynamicWorldBuilder` - `DynamicSceneRoot` -> `DynamicWorldRoot` - `SceneInstanceReady` -> `WorldInstanceReady` - `SceneLoader` -> `WorldAssetLoader` - `ScenePlugin` -> `WorldSerializationPlugin` - `SceneRootTemplate` -> `WorldAssetRootTemplate` - `SceneSpawner` -> `WorldInstanceSpawner` - `SceneFilter` -> `WorldFilter` - `SceneLoaderError` -> `WorldAssetLoaderError` - `SceneSpawnError` -> `WorldInstanceSpawnError` Note that I went with `bevy_world_serialization` over `bevy_ecs_serialization`, as that is what all of the internal features described themselves as. I think it is both more specific and does a better job of making itself decoupled from `bevy_ecs` proper.
1 parent 53ddd5e commit 535cf40

95 files changed

Lines changed: 2056 additions & 1936 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
File renamed without changes.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ example_showcase_config.ron
3232
example-showcase-reports/
3333

3434
# Generated by "examples/scene/scene.rs"
35-
assets/scenes/load_scene_example-new.scn.ron
35+
assets/serialized_worlds/load_scene_example-new.scn.ron
3636

3737
# Generated by "examples/window/screenshot.rs"
3838
**/screenshot-*.png

Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ audio = ["bevy_audio", "vorbis"]
164164
audio-all-formats = ["bevy_audio", "aac", "flac", "mp3", "mp4", "vorbis", "wav"]
165165

166166
# COLLECTION: Features used to compose Bevy scenes.
167-
scene = ["bevy_ecs_serialization", "bevy_scene2"]
167+
scene = ["bevy_world_serialization", "bevy_scene2"]
168168

169169
# COLLECTION: Enables picking with all backends.
170170
picking = ["bevy_picking", "mesh_picking", "sprite_picking", "ui_picking"]
@@ -318,7 +318,7 @@ bevy_picking = ["bevy_internal/bevy_picking"]
318318
bevy_render = ["bevy_internal/bevy_render"]
319319

320320
# Provides ECS serialization functionality
321-
bevy_ecs_serialization = ["bevy_internal/bevy_ecs_serialization"]
321+
bevy_world_serialization = ["bevy_internal/bevy_world_serialization"]
322322

323323
# Provides scene functionality
324324
bevy_scene2 = ["bevy_internal/bevy_scene2"]
@@ -3022,13 +3022,13 @@ wasm = false
30223022

30233023
# Scene
30243024
[[example]]
3025-
name = "scene"
3026-
path = "examples/scene/scene.rs"
3025+
name = "world_serialization"
3026+
path = "examples/scene/world_serialization.rs"
30273027
doc-scrape-examples = true
30283028

3029-
[package.metadata.example.scene]
3030-
name = "Scene"
3031-
description = "Demonstrates loading from and saving scenes to files"
3029+
[package.metadata.example.world_serialization]
3030+
name = "World Serialization"
3031+
description = "Demonstrates loading from and saving world to files"
30323032
category = "Scene"
30333033
wasm = false
30343034

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: "The old `bevy_scene` is now `bevy_world_serialization"
3+
pull_requests: [23619, 23630]
4+
---
5+
6+
In **Bevy 0.19** we landed a subset of Bevy's Next Generation Scene system (often known as BSN), which now lives in the `bevy_scene` / `bevy::scene` crate. However the old `bevy_scene` system still needs to stick around for a bit longer, as it provides some features that Bevy's Next Generation Scene system doesn't (yet!):
7+
8+
1. It is not _yet_ possible to write a World _to_ BSN, so the old system is still necessary for "round trip World serialization".
9+
2. The GLTF scene loader has not yet been ported to BSN, so the old system is still necessary to spawn GLTF scenes in Bevy.
10+
11+
For this reason, we have renamed the old `bevy_scene` crate to `bevy_world_serialization`. If you were referencing `bevy_scene::*` or `bevy::scene::*` types, rename those paths to `bevy_world_serialization::*` and `bevy::world_serialization::*` respectively.
12+
13+
Additionally, to avoid confusion / conflicts with the new scene system, all "scene" terminology / types have been reframed as "world serialization":
14+
15+
- `Scene` -> `WorldAsset` (as this was always just a World wrapper)
16+
- `SceneRoot` -> `WorldAssetRoot`
17+
- `DynamicScene` -> `DynamicWorld`
18+
- `DynamicScene::from_scene` -> `DynamicWorld::from_world_asset`
19+
- `DynamicSceneBuilder` -> `DynamicWorldBuilder`
20+
- `DynamicSceneRoot` -> `DynamicWorldRoot`
21+
- `SceneInstanceReady` -> `WorldInstanceReady`
22+
- `SceneLoader` -> `WorldAssetLoader`
23+
- `ScenePlugin` -> `WorldSerializationPlugin`
24+
- `SceneRootTemplate` -> `WorldAssetRootTemplate`
25+
- `SceneSpawner` -> `WorldInstanceSpawner`
26+
- `SceneFilter` -> `WorldFilter`
27+
- `SceneLoaderError` -> `WorldAssetLoaderError`
28+
- `SceneSpawnError` -> `WorldInstanceSpawnError`
29+
30+
GLTF scene spawning is the most likely source of breakage for most people, as round trip world serialization is a relatively niche use case. For most people, the migration should be as simple as:
31+
32+
```rust
33+
// before
34+
commands.spawn(SceneRoot(asset_server.load("scene.gltf#Scene0")));
35+
36+
// after
37+
commands.spawn(WorldAssetRoot(asset_server.load("scene.gltf#Scene0")));
38+
```
39+
40+
We know this naming is a bit awkward. Once we port GLTF loading over to BSN (hopefully in the next release), you will be able to do cool stuff like this:
41+
42+
```rust
43+
bsn! {
44+
:"scene.gltf#Scene0"
45+
Transform { position: Vec3 { x: 10. } }
46+
}
47+
```
48+
49+
This would set _just_ the `x` position in the GLTF scene root to `x`, patching on top of the position defined in the gltf scene. Cool!

assets/scenes/load_scene_example.scn.ron renamed to assets/serialized_worlds/load_scene_example.scn.ron

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(
22
resources: {
3-
"scene::ResourceA": (
3+
"world_serialization::ResourceA": (
44
score: 1,
55
),
66
},
@@ -14,19 +14,19 @@
1414
rotation: (0.0, 0.0, 0.0, 1.0),
1515
scale: (1.0, 1.0, 1.0),
1616
),
17-
"scene::ComponentA": (
17+
"world_serialization::ComponentA": (
1818
x: 1.0,
1919
y: 2.0,
2020
),
21-
"scene::ComponentB": (
21+
"world_serialization::ComponentB": (
2222
value: "hello",
2323
),
24-
"bevy_ecs_serialization::components::SceneRoot": (Path("models/FlightHelmet/FlightHelmet.gltf#Scene0")),
24+
"bevy_world_serialization::components::WorldAssetRoot": (Path("models/FlightHelmet/FlightHelmet.gltf#Scene0")),
2525
},
2626
),
2727
4294967298: (
2828
components: {
29-
"scene::ComponentA": (
29+
"world_serialization::ComponentA": (
3030
x: 3.0,
3131
y: 4.0,
3232
),

crates/bevy_app/src/main_schedule.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,9 @@ pub struct AnimationSystems;
203203
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
204204
pub enum SceneSpawnerSystems {
205205
/// Bevy's original scene system.
206-
SceneSpawn,
206+
WorldInstanceSpawn,
207207
/// Bevy's next-generation scene system
208-
Scene2Spawn,
208+
SceneSpawn,
209209
}
210210

211211
/// Defines the schedules to be run for the [`Main`] schedule, including

crates/bevy_ecs_serialization/README.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)