Add docs to custom vertex attribute example (#17422)

# Objective

The gltf-json crate seems like it strips/adds an `_` when doing the name
comparison for custom vertex attributes.

* gltf-json
[add](88e719d5de/gltf-json/src/mesh.rs (L341))
* gltf-json
[strip](88e719d5de/gltf-json/src/mesh.rs (L298C12-L298C42))
* [bevy's
handling](b66c3ceb0e/crates/bevy_gltf/src/vertex_attributes.rs (L273-L276))
seems like it uses the non-underscore'd version.

The bevy example gltf:
[barycentric.gltf](b66c3ceb0e/assets/models/barycentric/barycentric.gltf),
includes two underscores: `__BARYCENTRIC` in the gltf file, resulting in
needing `_BARYCENTRIC` (one underscore) as the attribute name in Bevy.
This extra underscore is redundant and does not appear if exporting from
blender, which only requires a single underscore to trigger the
attribute export.

I'm not sure if we want to change the example itself (maybe there's a
reason it has two underscores, I couldn't find a reason), but a docs
comment would help.

## Solution

add docs detailing the behavior
This commit is contained in:
Chris Biscardi 2025-01-20 13:16:11 -08:00 committed by GitHub
parent b2f3248432
commit 1dd30a620a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -33,6 +33,9 @@ fn main() {
DefaultPlugins.set(
GltfPlugin::default()
// Map a custom glTF attribute name to a `MeshVertexAttribute`.
// The glTF file used here has an attribute name with *two*
// underscores: __BARYCENTRIC
// One is stripped to do the comparison here.
.add_custom_vertex_attribute("_BARYCENTRIC", ATTRIBUTE_BARYCENTRIC),
),
Material2dPlugin::<CustomMaterial>::default(),