mirror of
https://github.com/bevyengine/bevy
synced 2024-11-26 14:40:19 +00:00
857fb9c724
# Objective - Fixes #9967 ## Solution - Remove `monkey.gltf` - Added `torus.gltf`, which is two torus meshes joined together, to replace `monkey.gltf` in the examples ## Examples I made `torus.gltf` mainly so that the multiple_windows example clearly shows the different camera angles ### asset_loading ![image](https://github.com/bevyengine/bevy/assets/425184/0ee51013-973d-4b23-9aa6-d254fecde7f1) ### hot_asset_reloading ![image](https://github.com/bevyengine/bevy/assets/425184/b2a2b1d8-167e-478b-b954-756ca0bbe469) ### multiple_windows: ![image](https://github.com/bevyengine/bevy/assets/425184/cb23de2c-9ff8-4843-a5c0-981e4d29ae49) ![image](https://github.com/bevyengine/bevy/assets/425184/b00bc2c7-66e8-4881-8fab-08269e223961)
49 lines
1.5 KiB
Rust
49 lines
1.5 KiB
Rust
//! Uses two windows to visualize a 3D model from different angles.
|
|
|
|
use bevy::{prelude::*, render::camera::RenderTarget, window::WindowRef};
|
|
|
|
fn main() {
|
|
App::new()
|
|
// By default, a primary window gets spawned by `WindowPlugin`, contained in `DefaultPlugins`
|
|
.add_plugins(DefaultPlugins)
|
|
.add_systems(Startup, setup_scene)
|
|
.add_systems(Update, bevy::window::close_on_esc)
|
|
.run();
|
|
}
|
|
|
|
fn setup_scene(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|
// add entities to the world
|
|
commands.spawn(SceneBundle {
|
|
scene: asset_server.load("models/torus/torus.gltf#Scene0"),
|
|
..default()
|
|
});
|
|
// light
|
|
commands.spawn(PointLightBundle {
|
|
transform: Transform::from_xyz(4.0, 5.0, 4.0),
|
|
..default()
|
|
});
|
|
// main camera, cameras default to the primary window
|
|
// so we don't need to specify that.
|
|
commands.spawn(Camera3dBundle {
|
|
transform: Transform::from_xyz(0.0, 0.0, 6.0).looking_at(Vec3::ZERO, Vec3::Y),
|
|
..default()
|
|
});
|
|
|
|
// Spawn a second window
|
|
let second_window = commands
|
|
.spawn(Window {
|
|
title: "Second window".to_owned(),
|
|
..default()
|
|
})
|
|
.id();
|
|
|
|
// second window camera
|
|
commands.spawn(Camera3dBundle {
|
|
transform: Transform::from_xyz(6.0, 0.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y),
|
|
camera: Camera {
|
|
target: RenderTarget::Window(WindowRef::Entity(second_window)),
|
|
..default()
|
|
},
|
|
..default()
|
|
});
|
|
}
|