-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Description
Bevy version
v0.12
What you did
Bevy panics when you spawn a Mesh from a GLTF asset that has an attached armature. The GLTF file I'm working with contains a single cube, with a single bone inside it. When I spawn it as #Scene0 it works fine, but when I only want to spawn the #Mesh0/Primitive0 it panics.
When I spawn it, the application crashes with:
2023-11-29T22:44:06.310929Z ERROR log: Handling wgpu errors as fatal by default thread '<unnamed>' panicked at /Users/dmlary/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.17.2/src/backend/direct.rs:3056:5: wgpu error: Validation Error
Caused by:
In a RenderPass
note: encoder = `<CommandBuffer-(0, 2, Metal)>`
In a draw command, indexed:true indirect:false
note: render pipeline = `pbr_opaque_mesh_pipeline`
The pipeline layout, associated with the current render pipeline, contains a bind group layout at index 2 which is incompatible with the bind group layout associated with the bind group at 2Source code used to load the asset.
use bevy::prelude::*;
fn main() {
let mut app = App::new();
app.add_plugins((DefaultPlugins,))
.add_systems(Startup, setup)
.run();
}
fn setup(
mut commands: Commands,
mut materials: ResMut<Assets<StandardMaterial>>,
asset_server: Res<AssetServer>,
) {
// XXX works fine
// let scene = asset_server.load("cube-with-bone.glb#Scene0");
// commands.spawn(SceneBundle { scene, ..default() });
// XXX panics during render
let mesh_handle: Handle<Mesh> = asset_server.load("cube-with-bone.glb#Mesh0/Primitive0");
commands.spawn(MaterialMeshBundle {
mesh: mesh_handle,
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
..default()
});
// camera
commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(10.0, 12.0, 16.0).looking_at(Vec3::ZERO, Vec3::Y),
..default()
});
}Questions
- Is there a way to spawn a Mesh from a GLTF without its Armature?
- How would we spawn the Mesh with its Armature?
- Example: How is a
GltfNodeconnected to the Armature? - Is there an
AssetServer::load()path that encompassesMeshandArmature?
- Example: How is a
- Is there any way to get a better error message when this happens?
Additional information
Zip file of both .blender and .glb files (thanks for the idea @alice-i-cecile): cube-with-bone.zip
blender file screenshot (because github no support gltf/blender files):

gltf file loaded in gltf viewer:

Another person brought up this issue in the discord recently: https://discord.com/channels/691052431525675048/1179374309882462239
Further background
The wider context for this is I'm working on a scene-less blender workflow for spawning objects, characters, etc from a GLTF file. I'm able to spawn the hierarchy from GltfNode1, but it panics if any Mesh had bones attached. Unless I'm missing something obvious, the Armature have been removed from the GltfNode, so I don't know that it should be spawned.