I'm having issues with Gltf assets. I'm trying to use the named_scenes feature specifically but Res<Asset<Gltf>>.get is always returning None.
fn spawn_named_ground(
mut commands: Commands,
ass: Res<AssetServer>,
assets_gltf: Res<Assets<Gltf>>,
) {
let gltf = ass.load("models/terrain_and_stuff.glb");
info!("gltf {:?}", gltf);
// Always None
if let Some(pack) = assets_gltf.get(&gltf) {
info!("pack found");
commands.spawn(SceneBundle {
scene: pack.named_scenes["Ground"].clone(),
transform: Transform::from_xyz(0., 0., 0.),
..default()
});
}
}
I'm able to spawn the entire scene using this, so I think my glb file is ok:
fn spawn_ground(mut commands: Commands, ass: Res<AssetServer>) {
let gltf = ass.load("models/terrain_and_stuff.glb#Scene0");
info!("gltf {:?}", gltf);
commands.spawn(SceneBundle {
scene: gltf.clone(),
transform: Transform::from_xyz(0., 0., 0.),
..default()
});
}
Any ideas what I'm missing?
bevy 0.13.2