bevy panics when spawning GLTF Mesh asset without associated bones/armature
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
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:
```txt
2023-11-29T22:44:06.310929Z ERROR log: Handling wgpu errors as fatal by default thread '' 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 = ``
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 2
```
Source code used to load the asset.
```rust
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>,
asset_server: Res,
) {
// 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 = 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 `GltfNode` connected to the Armature?
* Is there an `AssetServer::load()` path that encompasses `Mesh` and `Armature`?
* 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](https://github.com/bevyengine/bevy/files/13506450/cube-with-bone.zip)
blender file screenshot (because github no support gltf/blender files):
gltf file loaded in gltf viewer:
[full-panic-output.txt](https://github.com/bevyengine/bevy/files/13506248/mesh-panic.txt)
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 `GltfNode`[^spawn-url], 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.
[^spawn-url]: [spawn code in discord](https://discord.com/channels/691052431525675048/1178770911743201301/1178781393371811942)
Contributor guide
Assessment
This issue has not been assessed yet.