Import a model
-
Setup a window, a main game loop, and other main features with
DefaultPlugins.ch01/step-2-1- Bevy at its core is just a skeleton for supporting the ECS paradigm.
- A new Bevy app contains nothing; we add ECS to it to give it meanings.
- A plugin is a pack of ECS items that work together to handle a specific aspect of the game.
- Window management, game loop, input management, logging, are all supported through some default plugins.
-
Download a model to
assets/models/Fox.glb.- You can design your 3D model visually with software like Blender.
- Then you can export it to formats like glTF (or its binary version
.glb) to use it programmatically in Bevy.
-
Load this model in Bevy app
ch01/step-2-2- In the code we add
setupas a Bevy system atStartupphase of the game (in Bevy, systems are just functions). - Scene is kind of like a container: we can put one or more models, lights and cameras in it. It can be exported by 3D modeling software, and loaded by Bevy.
- Here we load a scene with an
AssetServer, and spawn it insetup:commands.spawn(SceneBundle { scene: asset_server.load("models/Fox.glb#Scene0"), ..default() });
- In the code we add
-
Observe it in the window with a camera
- let's set up a default camera for now
commands.spawn(Camera3dBundle::default());
- let's set up a default camera for now
-
Now run the game with
cargo run, you'll see something like this:

Note about the
setupsystem:
- In Bevy, we define normal Rust functions to represent all kinds of behaviors in the game world. In terms of ECS, these functions are often called systems.
- We mainly have two concerns about systems:
- What are they supposed to do?
- When are they executed?
- Simply put, a system takes something in a game world, and do something with them.
- In our
setupsystem (the name is arbitrary), we take access to the asset manager, and load an external model from the asset folder. Then, with mutable access toCommands, we generate (spawn) the loaded model and a camera in the game world.- The access to what we need in Bevy (e.g. all components of a certain type, some global resources), is acquired through the typing of the function parameter. We will see a lot more examples later.
- When you register your function as a system using
add_systems, you are also describing when to run this system. Typical choices areStartup(run once at start up) andUpdate(run one time each frame).