Add additional names to GLTF entities for easier querying #13473
Labels
A-Assets
Load files from disk to use for things like images, models, and sounds
C-Usability
A simple quality-of-life change that makes Bevy easier to use
What problem does this solve or what need does it fill?
I have a very simple blender file with a single mesh and multiple materials:
![image](https://private-user-images.githubusercontent.com/1215187/332871166-b485f425-8571-49d3-9f65-d9c77bacb4e6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ4NjEzMTcsIm5iZiI6MTcyNDg2MTAxNywicGF0aCI6Ii8xMjE1MTg3LzMzMjg3MTE2Ni1iNDg1ZjQyNS04NTcxLTQ5ZDMtOWY2NS1kOWM3N2JhY2I0ZTYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjhUMTYwMzM3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Y2Q1ZDBmZTEwMmM1Y2Q2NTJmZTFlZDJkODk5MzE3YjVmMDYwMjdjZjQyYmUyOWQ4NDJhZGY2ZWEwZjkxNTQ2ZCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.Gih4XL1jjOedFMlYgcuem4Hb_oihw-btZdrr0TAaYkE)
When exporting to GLTF it creates a mesh with multiple primitives:
![image](https://private-user-images.githubusercontent.com/1215187/332871434-3b724f09-e5df-4852-8ab6-21d598a6bd78.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ4NjEzMTcsIm5iZiI6MTcyNDg2MTAxNywicGF0aCI6Ii8xMjE1MTg3LzMzMjg3MTQzNC0zYjcyNGYwOS1lNWRmLTQ4NTItOGFiNi0yMWQ1OThhNmJkNzgucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjhUMTYwMzM3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZjM4ODIxMjQ0Mzc2MzQwNzlkYmFhMzIyNDg4ZjM1YjM1ZDllZDJmZjI0NTZlNDkyZTcwZGRiNzVlOTI0NzYxZSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.ZIeLcSY1HL3Kab_jx0gB0ypz0N1-UIVWn-KPe1Kchhs)
Bevy creates an entity for the node object and separate entity per each primitive of the mesh (no mesh-specific entity):
![image](https://private-user-images.githubusercontent.com/1215187/332870505-b280e132-8204-4056-ae7a-bf3d8263676a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ4NjEzMTcsIm5iZiI6MTcyNDg2MTAxNywicGF0aCI6Ii8xMjE1MTg3LzMzMjg3MDUwNS1iMjgwZTEzMi04MjA0LTQwNTYtYWU3YS1iZjNkODI2MzY3NmEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjhUMTYwMzM3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Mjk4NzU2NmZlNWU4YTM2YTIwMDk4ZTdmOWRmNzhlYmYzNzU4Yjc5M2JlZGEwNjIxMzkzNzEzYmJjZGJiOTEwMSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.u3ac5ggeo2DxXsV1_XHLFUwGk-sBln2PpDnJaDVTA_Q)
There are few problems:
What solution would you like?
I'd like to add more
Name
-like components to make querying much easier:Names are not enough in this case because:
In such case it will be trivial to find/replace components for any Gltf scene.
What alternative(s) have you considered?
I don't see currently any ECS friendly alternative.
We could also have
GltfInstance
component attached to the root node that will map entities by type/name but IMHO it is not really ECS way of doing things:Additional context
This is just a suggestion.
There are 100% better ways to solve this problem but we should improve Gltf usability for sure. Currently it just way to cumbersome and requires huge amount of boilerplate code.
The text was updated successfully, but these errors were encountered: