Bevy version and features
Version: Main #370be1b0
Features: Default Features + [
"dynamic_linking",
"debug"
]
What you did
Attempted to use ScenePatchInstance to spawn a scene from the asset server using Commands::queue_spawn_scene.
What went wrong
Scene failed to spawn
Scene will spawn successfully if ScenePatchInstance is spawn via Commands::spawn
It is unclear if this is intended behavior or not. If it is, this interaction should be noted in the documentation for ScenePatchInstance
Minimal Reproducible Sample
use bevy::{prelude::*, scene::ScenePatch};
fn main() {
let mut app = App::new();
app.add_plugins(DefaultPlugins).add_systems(Startup, setup);
app.run();
}
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
let scene = ScenePatch::load(&asset_server, display());
let handle = asset_server.add(scene);
//display_1
// Spawn via Commands::spawn
commands.spawn((
Transform::from_xyz(-4.0, 0.0, 0.0),
ScenePatchInstance(handle.clone()),
));
//display_2
// Spawn via bsn
commands.queue_spawn_scene(bsn!(
Transform::from_xyz(4.0, 0.0, 0.0)
ScenePatchInstance(handle)
));
// Camera & Light
commands.queue_spawn_scene_list(bsn_list!(
(
Camera3d
template_value(Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y))
),
(
PointLight {
shadow_maps_enabled: true,
}
Transform::from_xyz(4.0, 8.0, 4.0)
)
));
}
fn display() -> impl Scene {
bsn!(
template(|ctx| {
let mut assets = ctx.resource_mut::<Assets<Mesh>>();
let handle = assets.add(Cuboid::from_length(1.0));
Ok(Mesh3d(handle))
})
template(|ctx| {
let mut assets = ctx.resource_mut::<Assets<StandardMaterial>>();
let handle = assets.add(Color::WHITE);
Ok(MeshMaterial3d(handle))
})
)
}
Bevy version and features
Version: Main #370be1b0
Features: Default Features + [
"dynamic_linking",
"debug"
]
What you did
Attempted to use ScenePatchInstance to spawn a scene from the asset server using Commands::queue_spawn_scene.
What went wrong
Scene failed to spawn
Scene will spawn successfully if ScenePatchInstance is spawn via Commands::spawn
It is unclear if this is intended behavior or not. If it is, this interaction should be noted in the documentation for ScenePatchInstance
Minimal Reproducible Sample